item
This API provides interfaces to retrieve information of media contents.
The Item API provides access to the content information.
This item will be a folder, an audio, an image and an video item which it has retrieved from a digital media server (DMS).
Type Definition
ItemType
Specifies the item type
enum ItemType {
"AUDIO",
"FOLDER",
"IMAGE",
"UNKNOWN",
"VIDEO"
};
- AUDIO: audio type of the content
- FOLDER: folder type of the content
- IMAGE: image type of the content
- UNKNOWN: the unknown content
- VIDEO: video type of the content
ItemContentBuildType
Specifies a item origin.
enum ItemContentBuildType {
"LOCAL",
"MEDIAPROVIDER",
"UNKNOWN",
"WEB"
};
- LOCAL: the content is from the local device
- MEDIAPROVIDER: the content is from a remote media provider
- UNKNOWN: the content is from nowhere
- WEB: the content is from internet
ItemPlayMode
Specifies an item play mode.
enum ItemPlayMode {
"RELAY",
"REDIRECT",
"UNKNOWN"
};
- RELAY: the content will be downloaded and serves to the remote player
- REDIRECT : the content’s URL will be passed to the remote player
- UNKNOWN : the content play mode can’t be distingushed
Interfaces
Item
The object which represents a media content (audio, image, video) or a container (folder). An Item object will be retrieved by browse() or search() in provider APIs. Also, an Item object can be built with a local content or a web content with constructor.
[Constructor(DOMString uri, optional DOMString mimeType, optional DOMString title)] interface Item {
readonly attribute DOMString albumTitle;
readonly attribute DOMString artist;
readonly attribute Date date;
readonly attribute unsigned long long duration;
readonly attribute DOMString extension;
readonly attribute double fileSize;
readonly attribute DOMString genre;
readonly attribute SimpleCoordinates location;
readonly attribute DOMString mimeType;
readonly attribute unsigned long width;
readonly attribute unsigned long height;
readonly attribute DOMString subtitleUri;
readonly attribute DOMString thumbnailUri;
readonly attribute DOMString title;
readonly attribute ItemType itemType;
readonly attribute DOMString itemUri;
readonly attribute boolean isRootFolder;
readonly attribute ItemContentBuildType contentBuildType;
};
Code example
var serviceProvider; // it is assumed that you has obtained a serviceProvider object.
// For further details, see the createServiceProvider() or getServiceProvider().
var localContentsPath = "file://Videos/clip.mp4";
var webContentsUri = "http://mediashare.com/videos/clip.mp4";
var mimeType = "video/mp4";
// Type 1. create item with a local content.
var localItem = new Item(localContentsPath, mimeType. "Local Video Clip");
// Type 2. create item with a web content.
var webItem = new Item(webContentsUri, mimeType. "Web Video Clip");
// Type 3. retrieve an item from a remote provider.
var providerItem;
//Define browse callback
function browseCB(list, endOfItem, provider) {
providerItem = list[0];
}
function errorCB(error, device) {
console.log(device + " raises " + error);
}
// Define success callback for creating ServiceProvider
function sProviderCallback(provider) {
// Obtaining service provider instance.
serviceProvider = provider;
try {
var providers = serviceProvider.getDeviceFinder().getDevices("MEDIAPROVIDER");
if (providers.length > 0) {
// retrieves first DMS from the root folder
providers[0].browse(providers[0].rootFolder, 0, 1, browseCB, errorCB);
}
} catch(e) {
console.log(e.message);
}
}
// Define error callback for creating ServiceProvider
function eProviderCallback(error, state) {
console.log(error.name);
console.log("Service state: " + state);
}
try {
webapis.allshare.serviceconnector.createServiceProvider(sProviderCallback, eProviderCallback);
} catch(e) {
console.log(e.message);
}
ATTRIBUTES
readonly DOMString albumTitle
Content album title.
If it’s itemType value is “FOLDER”, “undefined” returns.
This attribute is readonly.
readonly DOMString artist
Content artist.
If it’s itemType value isn’t a “AUDIO”, “undefined” returns.
This attribute is readonly.
readonly Date date
Content date.
If it’s itemType value is “FOLDER”, “undefined” returns.
This attribute is readonly.
readonly unsigned long long duration
Content total play time.
If it’s itemType value is “FOLDER” or “IMAGE”, “undefined” returns.
This attribute is readonly.
readonly DOMString extension
Content extension.
If it’s itemType value is “FOLDER”, “undefined” returns.
This attribute is readonly.
readonly double fileSize
Content file size.
If it’s itemType value is a “FOLDER”, “undefined” returns.
This attribute is readonly.
readonly DOMString genre
Content genre.
If it’s itemType value is not an “AUDIO”, “undefined” returns.
This attribute is readonly.
readonly SimpleCoordinates? location
Content geo-location.
if the itemType value is a “FOLDER”, “undefined” returns.
This attribute is readonly.
readonly DOMString mimeType
Content MIME type.
This attribute is readonly.
readonly unsigned long width
Content width.
If it’s itemType value is not an “IMAGE” or “VIDEO”, “undefined” returns.
This attribute is readonly.
readonly unsigned long height
Content height.
If it’s itemType value is an “IMAGE” or “VIDEO”, “undefined” returns.
This attribute is readonly.
readonly DOMString subtitleUri
Content subtitle URI.
If it’s itemType value is not a “VIDEO”, “undefined” returns.
This attribute is readonly.
readonly DOMString thumbnailUri
Content thumbnail URI.
If it’s itemType value is not an “IMAGE” or “VIDEO”, “undefined” returns.
This attribute is readonly.
readonly DOMString title
Content title.
This attribute is readonly.
readonly ItemType itemType
Item type.
This attribute is readonly.
readonly DOMString itemUri
Item URI
This attribute is readonly.
readonly boolean isRootFolder
Specifies whether it is a root folder or not.
This attribute is readonly.
readonly ItemContentBuildType contentBuildType
Specifies the content build type
This attribute is readonly.