Samsung Electronics logo

Browsing Content

Learning how to browse and search for content directories and content items in directories is a basic content management skill:

  1. Retrieve the ContentManager interface instance using the webapis global object:

    var manager = webapis.content;
  2. To search for the content directories in the local device, use the getDirectories() method of the ContentManager interface. The method returns an array of ContentDirectories objects.

    function onDirectoryArraySuccess(directories)
       console.log("Found directories " + ", directories.length: " + directories.length);
       for (var i = 0; i < directories.length; i++)
          /* Retrieve folder-specific information */
    manager.getDirectories(onDirectoryArraySuccess, onError);
  3. To search for the content items in all directories, use the find() method of the ContentManager interface. The method returns an array of Content objects.

    function onContentItemArraySuccess(contents)
       for (var i=0; i < contents.length; i++)
          console.log(i + ":" + contents[i].type + ":" + contents[i].title + ":" + contents[i].mimeType);
    var contentType = "VIDEO";
    var filter = new webapis.AttributeFilter("type", "EXACTLY", contentType);
    manager.find(onContentItemArraySuccess, onError, null, filter);
    To retrieve a specific set of content items, you can specify a content directory (with the directory ID), filter, and sorting order for the search operation through the directoryId, filter and sortMode parameters (for attributes supported in the filter, see Content Filter Attributes).

    In this example, the directory ID is set to null (which means that all directories are searched), the filter retrieves all content items, and no sorting order is defined (which means that the default sorting order is used).