Samsung Electronics logo

Samsung Web API: Item


Introduction

The Item API provides access to the content information.

This item will be a folder, an audio clip, an image or a video item which it has retrieved from a digital media server (DMS).


Table of Contents


Summary of Interfaces and Methods

Interface Method
Item

1. Type Definitions

1.1. 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

1.2. 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

1.3. ItemPlayMode

Specifies an item play mode.

    enum ItemPlayMode { 
        "RELAY",
        "REDIRECT",
        "UNKNOWN"
    };
  • RELAY: the content will be downloaded and served to the remote player
  • REDIRECT : the content's URL will be passed to the remote player
  • UNKNOWN : the content play mode cannot be determined

2. Interfaces

2.1. Item

The object which represents media content (audio, image, video) or a container (folder).

    [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;
        

        attribute DOMString? subtitleUri;
        

        readonly attribute DOMString? thumbnailUri;
        

        attribute DOMString title;
        

        readonly attribute ItemType itemType;
        

        readonly attribute DOMString itemUri;
        

        readonly attribute boolean isRootFolder;
        

        readonly attribute ItemContentBuildType contentBuildType; 
    };

An Item object will be retrieved by browse() or search() in provider APIs. Also, an item object can be built with local content or web content with a constructor in the following manner: new webapis.Item(...).

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 webapis.Item(localContentsPath, mimeType. "Local Video Clip");

 // Type 2. create item with a web content.
 var webItem = new webapis.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 creation ServiceProvider
 function sProviderCallback(provider) { 
      
      // Obtain 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 its itemType value is "FOLDER", "undefined" is returned.

This attribute is read-only.

readonly DOMString artist

Content artist.

If its itemType value is not "AUDIO", "undefined" is returned.

This attribute is read-only.

readonly Date date

Content date.

If its itemType value is "FOLDER","undefined"; is returned.

This attribute is read-only.

readonly unsigned long long duration

Content total play time.

If its itemType value is "FOLDER" or "IMAGE", "undefined" is returned.

This attribute is read-only.

readonly DOMString extension

Content extension.

If its itemType value is "FOLDER", "undefined" is returned.

This attribute is read-only.

readonly double fileSize

Content file size.

If its itemType value is a "FOLDER", "undefined" is returned.

This attribute is read-only.

readonly DOMString genre

Content genre.

If its itemType value is not "AUDIO", "undefined" is returned.

This attribute is read-only.

readonly SimpleCoordinates? location

Content geo-location.

If the itemType value is "FOLDER", "undefined" is returned.

This attribute is read-only.

readonly DOMString mimeType

Content MIME type.

This attribute is read-only.

readonly unsigned long? width

Content width.

If its itemType value is not "IMAGE" or "VIDEO", "undefined" is returned.

This attribute is read-only.

readonly unsigned long? height

Content height.

If its itemType value is "IMAGE" or "VIDEO", "undefined" is returned.

This attribute is read-only.

DOMString? subtitleUri

Content subtitle URI.

If its itemType value is not "VIDEO", "undefined" is returned.

readonly DOMString? thumbnailUri

Content thumbnail URI.

If its itemType value is "FOLDER", "undefined" is returned. Else if its itemType value is "AUDIO", an URI of the album art image will return. Some content may not be able to generate a thumbnail, it will also return "undefined".

This attribute is read-only.

DOMString title

Content title.

readonly ItemType itemType

Item type.

This attribute is read-only.

readonly DOMString itemUri

Item URI

This attribute is read-only.

readonly boolean isRootFolder

Specifies whether or not it is a root folder.

This attribute is read-only.

readonly ItemContentBuildType contentBuildType

Specifies the content build type

This attribute is read-only.

3. Full WebIDL

module Item {


    enum ItemType { 
        "AUDIO",
        "FOLDER",
        "IMAGE", 
        "UNKNOWN", 
        "VIDEO"
    };
    

    enum ItemContentBuildType { 
        "LOCAL",
        "MEDIAPROVIDER",
        "UNKNOWN",
        "WEB"
    };
    

    enum ItemPlayMode { 
        "RELAY",
        "REDIRECT",
        "UNKNOWN"
    };
    
    
    [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;
        

        attribute DOMString? subtitleUri;
        

        readonly attribute DOMString? thumbnailUri;
        

        attribute DOMString title;
        

        readonly attribute ItemType itemType;
        

        readonly attribute DOMString itemUri;
        

        readonly attribute boolean isRootFolder;
        

        readonly attribute ItemContentBuildType contentBuildType; 
    };
};