top

Item API

To use Samsung Product API, 

<script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script>

Should be loaded in index.html

The Item API provides access to the content information.

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/allshare

Table of Contents

  1. 1. Type Definitions
    1. 1.1. ItemType
  2. 2. Interfaces
    1. 2.1. Item
  3. 3. Full WebIDL

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"
  };

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/allshare

The following values are supported

  • 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
 
 

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

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/allshare

Constructors


  Item(DOMString uri, optional DOMString mimeType, optional DOMString title)

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/allshare

Parameters:

  • uri: content path
  • mimeType [optional]: DOMString
  • title [optional]: content title

Code example:


  //*        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(...).
  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().getDeviceList("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.

    Since : 1.0

    Privilege level: public

    Privilege: http://developer.samsung.com/privilege/allshare

  • readonly DOMString artist
    Content artist.

    Since : 1.0

    Privilege level: public

    Privilege: http://developer.samsung.com/privilege/allshare

  • readonly Date date
    Content date.

    Since : 1.0

    Privilege level: public

    Privilege: http://developer.samsung.com/privilege/allshare

  • readonly unsigned long long duration
    Content total play time.

    Since : 1.0

    Privilege level: public

    Privilege: http://developer.samsung.com/privilege/allshare

  • readonly DOMString extension

    Content extension

    Since : 1.0

    Privilege level: public

    Privilege: http://developer.samsung.com/privilege/allshare

  • readonly double fileSize
    Content file size.

    Since : 1.0

    Privilege level: public

    Privilege: http://developer.samsung.com/privilege/allshare

  • readonly DOMString genre
    Content genre.

    Since : 1.0

    Privilege level: public

    Privilege: http://developer.samsung.com/privilege/allshare

  • readonly DOMString mimeType

    Content MIME type

    Since : 1.0

    Privilege level: public

    Privilege: http://developer.samsung.com/privilege/allshare

  • readonly optional unsigned long width
    Content width.

    Since : 1.0

    Privilege level: public

    Privilege: http://developer.samsung.com/privilege/allshare

  • readonly optional unsigned long height
    Content height.

    Since : 1.0

    Privilege level: public

    Privilege: http://developer.samsung.com/privilege/allshare

  • optional DOMString subtitleUri
    Content subtitle URI.

    Since : 1.0

    Privilege level: public

    Privilege: http://developer.samsung.com/privilege/allshare

  • readonly optional DOMString thumbnailUri
    Content thumbnail URI.

    Since : 1.0

    Privilege level: public

    Privilege: http://developer.samsung.com/privilege/allshare

  • DOMString title
    Content title.

    Since : 1.0

    Privilege level: public

    Privilege: http://developer.samsung.com/privilege/allshare

  • readonly ItemType itemType
    Item type.

    Since : 1.0

    Privilege level: public

    Privilege: http://developer.samsung.com/privilege/allshare

  • readonly DOMString itemUri
    Item URI

    Since : 1.0

    Privilege level: public

    Privilege: http://developer.samsung.com/privilege/allshare

  • readonly boolean isRootFolder
    Specifies whether or not it is a root folder.

    Since : 1.0

    Privilege level: public

    Privilege: http://developer.samsung.com/privilege/allshare

  • readonly ItemContentBuildType contentBuildType
    Specifies the content build type

    Since : 1.0

    Privilege level: public

    Privilege: http://developer.samsung.com/privilege/allshare

3. Full WebIDL


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

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