MediaServer API

Media Server API to discover and manage images, videos, and music.

Table of Contents


Summary of Interfaces and Methods

Interface Method
MediaContainer Promise upload (DOMString title, DOMString path);
Promise creatFolder ( title);
Navigator
MediaServerManager void scanNetwork ( );
MediaServerEvent
MediaServerIdEvent
MediaServer Promise upload (DOMString title);
Promise createFolder (DOMString title);
Promise browse (DOMString containerId, DOMString? sortMode, unsigned long? count, unsignedlong? offset);
Promise find (DOMString containerId, DOMString? searchFilter, DOMString? sortMode, unsigned long? count, unsigned long? offset);
Promise cancel ();
MediaContainerIdEvent

1. Interfaces

1.1 Terminology

TheEventHandler interface represents a callback used for event handlers as defined in.

The concepts queue a task and fire a simple event are defined.

The terms event handler and event handler event types are defined.

The Event interface and the Promiseinterface as well as the concept of a resolver are defined.

1.2 MediaContainer

The media container interface.
[NoInterfaceObject]
interface MediaContainer : MediaObject {
    readonly    attribute unsigned long? childCount;
    readonly    attribute boolean        canCreateContainer;
    readonly    attribute boolean        canDelete;
    readonly    attribute boolean        canUpload;
    readonly    attribute boolean        canRename;
    Promise upload (DOMString title, DOMString path);
    Promise createFolder (DOMString title);
};

Attributes

canCreateContainer of type boolean, readonly
True if a container can be created in this container.
canDelete of type boolean, readonly
True if an item can be deleted in this container.
canRename of type boolean, readonly
True if an item can be renamed in this container.
canUpload of type boolean, readonly
True if an item can be uploaded in this container.
childCount of type unsigned long, readonly nullable
Number of child media items and containers.

Methods

createFolder
Creates a folder on the server, under the current container. This method returns a new Promise to notify the caller about the operation success or failure.
title: DOMString
Return type: Promise
upload
Uploads a media item on the server, in the current container. This method returns a new Promise to notify the caller about the operation success or failure.
title: DOMString
path: DOMString
Return type: Promise

1.3. Navigator

This interface defines what is instantiated by the Navigator object. There will be a navigator.mediaserver object that allows access to the functionality of the MediaServerManager API.
partial interface Navigator {
    readonly attribute MediaServerManager mediaServer;
};
Navigator implements MediaServerManagerObject;

1.4. MediaServerManager

The MediaServerManager interface defines access to local network media servers discovery functionality.
[NoInterfaceObject] interface MediaServerManager {
    void scanNetwork ();
                attribute EventHandler onserverfound;
                attribute EventHandler onserverlost;
};

Attributes

onserverfound of type EventHandler,
Event handler called when the serverfound event is dispatched.
onserverlost of type EventHandler,
Event handler called when the serverlost event is dispatched.

Methods

scanNetwork
Scans local network for MediaServers.
No parameters.
Return type: void

Event handlers

The following are the event handlers (and their corresponding event handler types) that MUST be supported as attributes by the MediaServerManager object.
event handler event name event type short description
onserverfound serverfound MediaServerEvent with server property set to the new MediaServer object. Fired when a MediaServer appears on the local network.
onserverlost serverfound MediaServerIdEvent with id property set to a DOMString with the id of the lost MediaServer. Fired when a MediaServer disappears from the local network.

1.5. MediaServerEvent

interface MediaServerEvent : Event {
    readonly    attribute MediaServer server;
};

Attributes

server of type MediaServer, readonly
When getting, the user agent MUST return the MediaServer that triggered the event.

1.6. MediaServerIdEvent

interface MediaServerIdEvent : Event {
    readonly    attribute DOMString id;
};

Attributes

id of type DOMString, readonly
When getting, the user agent MUST return the id of the MediaServer that triggered the event.

1.7. MediaServer

The MediaServer interface.
[NoInterfaceObject] interface MediaServer {

    readonly    attribute DOMString       id;
    readonly    attribute DOMString       friendlyName;
    readonly    attribute DOMString?      manufacturer;
    readonly    attribute DOMString?      manufacturerURL;
    readonly    attribute DOMString?      modelDescription;
    readonly    attribute DOMString?      modelName;
    readonly    attribute DOMString?      modelNumber;
    readonly    attribute DOMString?      serialNumber;
    readonly    attribute DOMString?      UDN;
    readonly    attribute DOMString?      presentationURL;
    readonly    attribute DOMString?      iconURL;
    readonly    attribute DOMString?      deviceType;
    readonly    attribute MediaContainer? root;
    readonly    attribute boolean         canCreateContainer;
    readonly    attribute boolean         canUpload;
    readonly    attribute DOMString[]     searchAttrs;
    readonly    attribute DOMString[]     sortAttrs;
    Promise upload (DOMString path);
    Promise browse(DOMString containerId, DOMString? sortMode, unsigned long? count, unsigned long? offset);
    Promise find(DOMString containerId, DOMString searchFilter, DOMString? sortMode, unsigned long? count, unsigned long? offset);
    Promise cancel ();
                attribute EventHandler    oncontainerchanged;
};

Attributes

UDN of type DOMString, readonly , nullable
The Unique Device Name of the server.
canCreateContainer of type boolean, readonly
True if a container can be created on this server, at a location managed by the server.
canUpload of type boolean, readonly
True if an item can be uploaded on this server, at a location managed by the server.
deviceType of type DOMString, readonly , nullable
The UPnP type of the device.
friendlyName of type DOMString, readonly , nullable
A user-friendly name for the device.
iconURL of type DOMString, readonly , nullable
A URL pointing to an icon that graphically identifies the server
id of type DOMString, readonly , nullable
An opaque unique ID.
manufacturer of type DOMString, readonly , nullable
A string identifying the manufacturer of the server.
manufacturerURL of type DOMString, readonly , nullable
A URL pointing to the manufacturer's web site.
modelDescription of type DOMString, readonly , nullable
A description of the server.
modelName of type DOMString, readonly , nullable
The model name of the server.
modelNumber of type DOMString, readonly , nullable
The server's version number.
oncontainerchanged of type EventHandler,
Event handler called when the containerchanged event of type MediaContainerIdEvent is dispatched. The id property of the event MAY contain the id of a MediaContainer object which content was modified, if the server supports it.
presentationURL of type DOMString, readonly , nullable
The URL of the server's HTML management interface.
root of type DOMString, readonly , nullable
Media Server root folder.
searchAttrs of type DOMString, readonly
List of attributes that can be used in search queries.
serialNumber of type DOMString, readonly , nullable
The server's serial number.
sortAttrs of type DOMString, readonly
List of attributes that can be used to sort search or browse action results.

Methods

browse
Browses for media item under a given MediaContainer. This method returns a new Promise that will notify the caller with the result of the operation, which is an Array of MediaObjects.
void browse(DOMString containerId, DOMString sortMode, unsigned long count, unsigned long offset);

Parameters:

  • containerId: A unique identifier for media container in a media server.
  • sortMode: Sort mode for media items.
  • count: The maximum number of media items to return out of the browse result (0 for no limit).
  • offset: The (0-based) index of the first item in the browse result.

Exceptions:

  • WebAPIError
    • with error type UnknownError, if an error occurs.

cancel
Cancels all requests a client has outstanding on that server. This method returns a new Promise to notify the caller about the operation success or failure.
Promise cancel ();
            attribute EventHandler    oncontainerchanged;
createFolder
Creates a folder on the server. This method returns a new Promise to notify the caller about the operation success or failure.
Promise createFolder (DOMString title);
find
Searches for media item under a given MediaContainer. This method returns a new Promise that will notify the caller with the result of the operation, which is an Array of MediaObjects.
void find(DOMString containerId, DOMString searchFilter, DOMString sortMode, unsigned long count, unsigned long offset);

Parameters:

  • containerId: A unique identifier for media container in a media server.
  • searchFilter: The search criteria string.
  • sortMode: Sort mode for media items.
  • count: The maximum number of media items to return out of the browse result (0 for no limit).
  • offset: The (0-based) index of the first item in the browse result.

Exceptions:

  • WebAPIError
    • with error type UnknownError, if an error occurs.

upload
Uploads a media item on the server. This method returns a new Promise to notify the caller about the operation success or failure.
 Promise upload (DOMString path);

Event handlers

The following are the event handlers (and their corresponding event handler types) that MUST be supported as attributes by the MediaServer object.
event handler event name event type short description
oncontainerchanged containerchanged MediaContainerIdEvent with id property set to a DOMString with the id of a MediaContainer. Fired when content was added, removed or modified in a given MediaContainer on the MediaServer.

1.8. MediaContainerIdEvent

interface MediaContainerIdEvent : Event {
    readonly    attribute DOMString id;
};

Attributes

id of type DOMString, readonly
When getting, the user agent MUST return the id of the MediaContainer that triggered the event.

3. Full WebIDL

module MediaServer {
    [NoInterfaceObject] interface MediaContainer : MediaObject {
        readonly    attribute unsigned long? childCount;
        readonly    attribute boolean        canCreateContainer;
        readonly    attribute boolean        canDelete;
        readonly    attribute boolean        canUpload;
        readonly    attribute boolean        canRename;
        Promise upload (DOMString title, DOMString path);
        Promise createFolder (DOMString title);
    };

    Navigator implements MediaServerManagerObject;

    [NoInterfaceObject] interface Navigator {
        readonly attribute MediaServerManager mediaServer;
    };

    [NoInterfaceObject] interface MediaServerManager  {

        void scanNetwork();
                    attribute EventHandleronserverfound;
                    attribute EventHandleronserverlost;
    };

    interface MediaServerEvent : Event {
        readonly    attribute MediaServer server;
    };

    interface MediaServerIdEvent : Event {
        readonly    attribute DOMString id;
    };

    [NoInterfaceObject] interface MediaServer {
        readonly    attribute DOMString       id;
        readonly    attribute DOMString       friendlyName;
        readonly    attribute DOMString?      manufacturer;
        readonly    attribute DOMString?      manufacturerURL;
        readonly    attribute DOMString?      modelDescription;
        readonly    attribute DOMString?      modelName;
        readonly    attribute DOMString?      modelNumber;
        readonly    attribute DOMString?      serialNumber;
        readonly    attribute DOMString?      UDN;
        readonly    attribute DOMString?      presentationURL;
        readonly    attribute DOMString?      iconURL;
        readonly    attribute DOMString?      deviceType;
        readonly    attribute MediaContainer? root;
        readonly    attribute boolean         canCreateContainer;
        readonly    attribute boolean         canUpload;
        readonly    attribute DOMString[]     searchAttrs;
        readonly    attribute DOMString[]     sortAttrs;
        Promise upload (DOMString path);
        Promise browse(DOMString containerId, DOMString? sortMode, unsigned long? count, unsigned long? offset);
        Promise find(DOMString containerId, DOMString searchFilter, DOMString? sortMode, unsigned long? count, unsigned long? offset);
        Promise cancel ();
                    attribute EventHandler    oncontainerchanged;

    };

    interface MediaContainerIdEvent : Event {
        readonly    attribute DOMString id;
    };
};