top

Content API

The Content API provides functionality to discover content such as images, videos, music, or others.

It is possible to search for specific content using filters. The API also supports setting the attributes of specific content.

For more information on the Content features, see Stored Content Management Guide.

Playlist functionality has been added in Tizen 2.3.

Since: 2.0

Table of Contents

  1. 1. Type Definitions
    1. 1.1. ContentDirectoryStorageType
    2. 1.2. ContentType
    3. 1.3. AudioContentLyricsType
    4. 1.4. ImageContentOrientation
    5. 1.5. ContentId
    6. 1.6. ContentDirectoryId
    7. 1.7. PlaylistId
  2. 2. Interfaces
    1. 2.1. ContentManagerObject
    2. 2.2. ContentManager
    3. 2.3. ContentArraySuccessCallback
    4. 2.4. ContentDirectoryArraySuccessCallback
    5. 2.5. ContentScanSuccessCallback
    6. 2.6. ContentChangeCallback
    7. 2.7. ContentDirectory
    8. 2.8. Content
    9. 2.9. VideoContent
    10. 2.10. AudioContentLyrics
    11. 2.11. AudioContent
    12. 2.12. ImageContent
    13. 2.13. PlaylistItem
    14. 2.14. Playlist
    15. 2.15. PlaylistArraySuccessCallback
    16. 2.16. PlaylistSuccessCallback
    17. 2.17. PlaylistItemArraySuccessCallback
    18. 2.18. ThumbnailSuccessCallback
  3. 3. Full WebIDL

Summary of Interfaces and Methods

Interface Method
ContentManagerObject
ContentManager
void update (Content content)
void updateBatch (Content[] contents, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
void getDirectories (ContentDirectoryArraySuccessCallback successCallback, optional ErrorCallback? errorCallback)
void find (ContentArraySuccessCallback successCallback, optional ErrorCallback? errorCallback, optional ContentDirectoryId? directoryId, optional AbstractFilter? filter, optional SortMode? sortMode, optional unsigned long? count, optional unsigned long? offset)
void scanFile (DOMString contentURI, optional ContentScanSuccessCallback? successCallback, optional ErrorCallback? errorCallback)
void scanDirectory (DOMString contentDirURI, boolean recursive, optional ContentScanSuccessCallback? successCallback, optional ErrorCallback? errorCallback)
void cancelScanDirectory (DOMString contentDirURI)
void removeChangeListener (long listenerId)
void getPlaylists (PlaylistArraySuccessCallback successCallback, optional ErrorCallback? errorCallback)
void createPlaylist (DOMString name, PlaylistSuccessCallback successCallback, optional ErrorCallback? errorCallback, optional Playlist? sourcePlaylist)
void removePlaylist (PlaylistId id, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
void createThumbnail (Content content, ThumbnailSuccessCallback successCallback, optional ErrorCallback? errorCallback)
ContentArraySuccessCallback
void onsuccess (Content[] contents)
ContentDirectoryArraySuccessCallback
void onsuccess (ContentDirectory[] directories)
ContentScanSuccessCallback
void onsuccess (DOMString uri)
ContentChangeCallback
void oncontentadded (Content content)
void oncontentupdated (Content content)
ContentDirectory
Content
VideoContent
AudioContentLyrics
AudioContent
ImageContent
PlaylistItem
Playlist
void add (Content item)
void addBatch (Content[] items, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
void remove (PlaylistItem item)
void removeBatch (PlaylistItem[] items, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
void get (PlaylistItemArraySuccessCallback successCallback, optional ErrorCallback? errorCallback, optional long? count, optional long? offset)
void setOrder (PlaylistItem[] items, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
void move (PlaylistItem item, long delta, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
PlaylistArraySuccessCallback
void onsuccess (Playlist[] playlists)
PlaylistSuccessCallback
void onsuccess (Playlist playlist)
PlaylistItemArraySuccessCallback
void onsuccess (PlaylistItem[] items)
ThumbnailSuccessCallback
void onsuccess (DOMString path)

1. Type Definitions

1.1. ContentDirectoryStorageType

  enum ContentDirectoryStorageType { "INTERNAL", "EXTERNAL" };

Since: 2.0

Defines whether a content directory is stored on internal or external storage (such as a removable memory card).

1.2. ContentType

  enum ContentType { "IMAGE", "VIDEO", "AUDIO", "OTHER" };

Since: 2.0

Defines the type of content such as an image, video, audio, or any other.

Remark : "OTHER" type is added since Tizen 2.1.

1.3. AudioContentLyricsType

  enum AudioContentLyricsType { "SYNCHRONIZED", "UNSYNCHRONIZED" };

Since: 2.0

Defines whether the lyrics supplied with an audio file is time-synchronized.

1.4. ImageContentOrientation

  enum ImageContentOrientation { "NORMAL", "FLIP_HORIZONTAL", "ROTATE_180", "FLIP_VERTICAL", "TRANSPOSE", "ROTATE_90", "TRANSVERSE", "ROTATE_270" };

Since: 2.0

Defines the orientation of an image.

1.5. ContentId

Content identifier.
  typedef DOMString ContentId;

Since: 2.0

1.6. ContentDirectoryId

Content directory identifier.
  typedef DOMString ContentDirectoryId;

Since: 2.0

1.7. PlaylistId

Playlist identifier.
  typedef DOMString PlaylistId;

Since: 2.3

2. Interfaces

2.1. ContentManagerObject

Defines what is instantiated by the Tizen object.
  [NoInterfaceObject] interface ContentManagerObject {
    readonly attribute ContentManager content;
  };
  Tizen implements ContentManagerObject;

Since: 2.0

The tizen.content object allows accessing the functionality of the Content module.

2.2. ContentManager

The ContentManager interface provides operations to retrieve and manipulate content.
  [NoInterfaceObject] interface ContentManager {

    void update(Content content) raises(WebAPIException);

    void updateBatch(Content[] contents,
                     optional SuccessCallback? successCallback,
                     optional ErrorCallback? errorCallback) raises(WebAPIException);

    void getDirectories(ContentDirectoryArraySuccessCallback successCallback,
                        optional ErrorCallback? errorCallback) raises(WebAPIException);

    void find(ContentArraySuccessCallback successCallback,
              optional ErrorCallback? errorCallback,
              optional ContentDirectoryId? directoryId,
              optional AbstractFilter? filter,
              optional SortMode? sortMode,
              optional unsigned long? count,
              optional unsigned long? offset) raises(WebAPIException);


    void scanFile(DOMString contentURI,
                  optional ContentScanSuccessCallback? successCallback,
                  optional ErrorCallback? errorCallback) raises(WebAPIException);

    void scanDirectory(DOMString contentDirURI,
                       boolean recursive,
                       optional ContentScanSuccessCallback? successCallback,
                       optional ErrorCallback? errorCallback) raises(WebAPIException);

    void cancelScanDirectory(DOMString contentDirURI) raises(WebAPIException);

    long addChangeListener(ContentChangeCallback changeCallback) raises(WebAPIException);

    void removeChangeListener(long listenerId) raises(WebAPIException);

    void setChangeListener(ContentChangeCallback changeCallback) raises(WebAPIException);

    void unsetChangeListener() raises(WebAPIException);

    void getPlaylists(PlaylistArraySuccessCallback successCallback,
                      optional ErrorCallback? errorCallback) raises(WebAPIException);

    void createPlaylist(DOMString name,
                        PlaylistSuccessCallback successCallback,
                        optional ErrorCallback? errorCallback,
                        optional Playlist? sourcePlaylist) raises(WebAPIException);

    void removePlaylist(PlaylistId id,
                        optional SuccessCallback? successCallback,
                        optional ErrorCallback? errorCallback) raises(WebAPIException);

    void createThumbnail(Content content,
                         ThumbnailSuccessCallback successCallback,
                         optional ErrorCallback? errorCallback) raises(WebAPIException);
  };

Since: 2.0

Methods

update
Updates attributes of content in the content database synchronously.
void update(Content content);
             

Since: 2.0

When an application has changed some attributes of the content, this method allows writing it back to the content database.

Privilege level: public

Privilege: http://tizen.org/privilege/content.write

Remark : The editableAttributes in the Content interface indicates the attributes that can be changed. This API does not support updating the metadata of a file.

Parameters:

  • content: The content to update.

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    • with error type InvalidValuesError, if any of the input parameters contain an invalid value.

    • with error type SecurityError, if the application does not have the privilege to call this method.

    • with error type UnknownError, in any other error case.

Code example:

 // Assume the content is a Content object as a result of find method.
 // Check the description is editable, and then set a description.
 if (content.editableAttributes.indexOf("description") >= 0) {
     content.description = "Sample content";
 }
 tizen.content.update(content);
 
updateBatch
Updates a batch of content attributes in the content database asynchronously.
void updateBatch(Content[] contents, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
             

Since: 2.0

When an application has changed any attributes in the array of content, this method allows writing them back to the content database.

The errorCallback is launched with these error types:

  • InvalidValuesError: If any of the input parameters contain an invalid value.
  • UnknownError: In any other error case.

Privilege level: public

Privilege: http://tizen.org/privilege/content.write

Remark : The editableAttributes in the Content interface indicates the attributes that can be changed. This API does not support updating the metadata of a file.

Parameters:

  • contents: Array of content to change.
  • successCallback [optional] [nullable]: Callback method to be invoked when attributes have been changed.
  • errorCallback [optional] [nullable]: Callback method to be invoked when an error has occurred.

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.

    • with error type SecurityError, if the application does not have the privilege to call this method.

Code example:

 // The following example increases rating of an content by 1

 function errorCB(err) {
     console.log( 'The following error occurred: ' +  err.name);
 }

 function successCB() {
     console.log('Attributes set successfully');
 }

 // Assume the content is a Content object as a result of find method.
 // Check the rating is editable, and then increase by 1.
 if (content.editableAttributes.indexOf("rating") >= 0) {
     content.rating++;
 }
 tizen.content.updateBatch([content], successCB, errorCB);
 
getDirectories
Gets a list of content directories.
void getDirectories(ContentDirectoryArraySuccessCallback successCallback, optional ErrorCallback? errorCallback);
             

Since: 2.0

This method returns (via callback) a list of content directory objects. To obtain a list of contents in a specific directory, use the find() method with the directory ID.

The errorCallback is launched with this error type:

  • UnknownError: In any other error case.

Parameters:

  • successCallback: Callback method to be invoked when content directories have been retrieved successfully.
  • errorCallback [optional] [nullable]: Callback method to be invoked when an error has occurred.

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.

Code example:

 // The following example retrieves content directories in the storage.

 function errorCB(err) {
     console.log( 'The following error occurred: ' +  err.name);
 }

 function printDirectory(directory, index, directories) {
     console.log('directoryURI: ' + directory.directoryURI + ' Title: ' + directory.title);
 }
 function getDirectoriesCB(directories) {
     directories.forEach(printDirectory);
 }

 tizen.content.getDirectories(getDirectoriesCB, errorCB);
 
find
Finds contents that satisfy the conditions set by a filter.
void find(ContentArraySuccessCallback successCallback, optional ErrorCallback? errorCallback, optional ContentDirectoryId? directoryId, optional AbstractFilter? filter, optional SortMode? sortMode, optional unsigned long? count, optional unsigned long? offset);
             

Since: 2.0

This method allows searching based on a supplied filter. For more details on AbstractFilter, see the Tizen module. The filter allows precise searching such as "return all songs by artist U2, ordered by name".

The errorCallback is launched with these error types:

  • InvalidValuesError: If any of the input parameters contain an invalid value.
  • UnknownError: In any other error case.

Privilege level: public

Privilege: http://tizen.org/privilege/content.read

Parameters:

  • successCallback: Callback method to be invoked when content has been retrieved.
  • errorCallback [optional] [nullable]: Callback method to be invoked when an error has occurred.
  • directoryId [optional] [nullable]: Directory ID that is used to select content to retrieve in a specified directory.
  • filter [optional] [nullable]: Filter that is used to select content to retrieve.
  • sortMode [optional] [nullable]: Used to determine the sort order in which the contents are returned.
  • count [optional] [nullable]: Maximum amount of content to return. If count is negative, InvalidValuesError is reported through the errorCallback.
  • offset [optional] [nullable]: Offset of the result set. If offset is a negative number, InvalidValuesError is reported through the errorCallback.

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.

    • with error type SecurityError, if the application does not have the privilege to call this method.

Code example:

 // The following example retrieves all songs from the album "The Joshua Tree", by artist "U2", ordered by the name.
 var count = 100;
 var offset = 0;
 var sortMode = new tizen.SortMode("name", "ASC");
 var artistFilter = new tizen.AttributeFilter("artists", "EXACTLY", "U2");
 var albumFilter = new tizen.AttributeFilter("album", "EXACTLY", "The Joshua Tree");
 var filter = new tizen.CompositeFilter("INTERSECTION", [albumFilter, artistFilter]);

 function errorCB(err) {
     console.log( 'The following error occurred: ' +  err.name);
 }

 function printContent(content, index, contents) {
     console.log('Name: ' + content.name + ' Title: ' + content.title + 'URL: ' + content.contentURI + 'MIME: ' + content.mimeType);
 }

 function findCB(contents) {
     console.log('The Joshua Tree by U2:');
     contents.forEach(printContent);
     // Increase the offset as much as the count and then find content again.
     if (contents.length === count) {
         offset += count;
         tizen.content.find(findCB, errorCB, null, filter, sortMode, count, offset);
     }
 }

 tizen.content.find(findCB, errorCB, null, filter, sortMode, count, offset);

 
scanFile
Scans a file to create or update content in the content database.
void scanFile(DOMString contentURI, optional ContentScanSuccessCallback? successCallback, optional ErrorCallback? errorCallback);
             

Since: 2.1

When an application creates or updates content, this method allows to scan it and then insert or update the content in the content database.

The errorCallback is launched with these error types:

  • UnknownError: In case of any error detected asynchronously

Privilege level: public

Privilege: http://tizen.org/privilege/content.write

Parameters:

  • contentURI: URI of content to scan.
  • successCallback [optional] [nullable]: Callback method to be invoked when scanning has been completed.
  • errorCallback [optional] [nullable]: Callback method to be invoked when an error has occurred.

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    • with error type InvalidValuesError, if any of the input parameters contain an invalid value (e.g. given contentURI is an empty string).

    • with error type SecurityError, if the application does not have the privilege to call this method.

Code example:

 // The following example scan 'tizen.jpg' in media directory

 function errorCB(err) {
     console.log( 'The following error occurred: ' +  err.name);
 }

 function successCB(path) {
     console.log('scanning is completed');
 }

 tizen.filesystem.resolve("images/tizen.jpg", function(imageFile) {
     tizen.content.scanFile(imageFile.toURI(), successCB, errorCB);
 });

 
scanDirectory
Scans a content directory to create or update content in the content database.
void scanDirectory(DOMString contentDirURI, boolean recursive, optional ContentScanSuccessCallback? successCallback, optional ErrorCallback? errorCallback);
             

Since: 2.4

When an application creates or updates content in a directory, this method allows to scan it and then insert or update the content in the content database. If a directory must not be scanned, the file .scan_ignore has to be created in it.

The errorCallback is launched with these error types:

  • UnknownError: In case of any error detected asynchronously

Privilege level: public

Privilege: http://tizen.org/privilege/content.write

Parameters:

  • contentDirURI: URI of a content directory to scan.
  • recursive: Used to determine whether the function makes recursive scan or not.
    If set to true, the function makes recursive scan.
  • successCallback [optional] [nullable]: Callback method to be invoked when scanning has been completed.
  • errorCallback [optional] [nullable]: Callback method to be invoked when an error has occurred.

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    • with error type InvalidValuesError, if any of the input parameters contain an invalid value (e.g. given contentDirURI is an empty string).

    • with error type SecurityError, if the application does not have the privilege to call this method.

    • with error type UnknownError, if any other error occurs.

Code example:

 // The following example scans 'images' directory

 function errorCB(err) {
     console.log( 'The following error occurred: ' +  err.name);
 }

 function successCB(path) {
     console.log('scanning is completed');
 }

 tizen.filesystem.resolve("images", function(directory) {
     tizen.content.scanDirectory(directory.toURI(), true, successCB, errorCB);
 });

 
cancelScanDirectory
Cancels a scan process of a content directory.
void cancelScanDirectory(DOMString contentDirURI);
             

Since: 2.4

When a scan of a given directory is running it may be canceled by this function.

Privilege level: public

Privilege: http://tizen.org/privilege/content.write

Parameters:

  • contentDirURI: URI of a content directory with a scan process running which is canceled.

Exceptions:

  • WebAPIException
    • with error type InvalidValuesError, if any of the input parameters contain an invalid value (e.g. given contentDirURI is an empty string).

    • with error type SecurityError, if the application does not have the privilege to call this method.

    • with error type UnknownError, if any other error occurs.

Code example:

 tizen.content.cancelScanDirectory(directory.toURI());

 
addChangeListener
Adds a listener which receives notifications when content changes.
long addChangeListener(ContentChangeCallback changeCallback);
             

Since: 3.0

Parameters:

  • changeCallback: Callback to be invoked when a content change is detected.

Return value:

long Identifier of the newly added listener.

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    • with error type AbortError, if the operation cannot be finished properly.

Code example:

 var listener = {
    oncontentadded: function(content) {
        console.log(content.contentURI + ' content is added');
    },
    oncontentupdated: function(content) {
        console.log(content.contentURI + ' content is updated');
    },
    oncontentremoved: function(id) {
        console.log(id + ' is removed');
    },
    oncontentdiradded: function(contentDir) {
        console.log(contentDir.directoryURI + ' content directory is added');
    },
    oncontentdirupdated: function(contentDir) {
        console.log(contentDir.directoryURI + ' content directory is updated');
    },
    oncontentdirremoved: function(id) {
        console.log(id + ' directory is removed');
    }
 };

 // Adds the listener
 var listenerId = tizen.content.addChangeListener(listener);

 console.log('Listener ID: ' + listenerId);
 

Output example:

 Listener ID: 1
 
removeChangeListener
Removes a listener which receives notifications about content changes.
void removeChangeListener(long listenerId);
             

Since: 3.0

Parameters:

  • listenerId: Identifier of the listener to be removed. It is returned by addChangeListener() when a listener is successfully added.

Exceptions:

  • WebAPIException
    • with error type AbortError, if the operation cannot be finished properly.

Code example:

 var listener = {
    oncontentadded: function(content) {
        console.log(content.contentURI + ' content is added');
    },
    oncontentupdated: function(content) {
        console.log(content.contentURI + ' content is updated');
    },
    oncontentremoved: function(id) {
        console.log(id + ' is removed');
    },
    oncontentdiradded: function(contentDir) {
        console.log(contentDir.directoryURI + ' content directory is added');
    },
    oncontentdirupdated: function(contentDir) {
        console.log(contentDir.directoryURI + ' content directory is updated');
    },
    oncontentdirremoved: function(id) {
        console.log(id + ' directory is removed');
    }
 };

 var listenerId = tizen.content.addChangeListener(listener);

 // Do some job here and when the listener is not needed anymore remove it

 // Removes the listener
 tizen.content.removeChangeListener(listenerId);
 
setChangeListener
Sets a listener to receive notifications of content changes.

Deprecated. Deprecated since 3.0. Instead, addChangeListener() allows application developers to add a listener and get notified when content is added, removed or updated on a device.

void setChangeListener(ContentChangeCallback changeCallback);
             

Since: 2.1

Privilege level: public

Privilege: http://tizen.org/privilege/content.read

Parameters:

  • changeCallback: A callback to be invoked for receiving a content change notification.

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    • with error type InvalidValuesError, if any of the input parameters contain an invalid value.

    • with error type SecurityError, if the application does not have the privilege to call this method.

    • with error type UnknownError, if any other error occurs.

Code example:

 var listener= {
    oncontentadded: function(content) {
        console.log(content.contentURI + ' content is added');
    },
    oncontentupdated: function(content) {
        console.log(content.contentURI + ' content is updated');
    },
    oncontentremoved: function(id) {
        console.log(id + ' is removed');
    },
    oncontentdiradded: function(contentDir) {
        console.log(contentDir.directoryURI + ' content directory is added');
    },
    oncontentdirupdated: function(contentDir) {
        console.log(contentDir.directoryURI + ' content directory is updated');
    },
    oncontentdirremoved: function(id) {
        console.log(id + ' directory is removed');
    }
 };

 // Registers to be notified when the content changes
 tizen.content.setChangeListener(listener);

 
unsetChangeListener
Unsets the listener to unsubscribe from receiving notifications for content changes.

Deprecated. Deprecated since 3.0. Instead, use removeChangeListener().

void unsetChangeListener();
             

Since: 2.1

Privilege level: public

Privilege: http://tizen.org/privilege/content.read

Exceptions:

  • WebAPIException
    • with error type SecurityError, if the application does not have the privilege to call this method.

    • with error type UnknownError, if any other error occurs.

Code example:

 tizen.content.unsetChangeListener();

 
getPlaylists
Gets all playlists.
void getPlaylists(PlaylistArraySuccessCallback successCallback, optional ErrorCallback? errorCallback);
             

Since: 2.3

The errorCallback is launched with these error types:

  • UnknownError: In case of any error

Privilege level: public

Privilege: http://tizen.org/privilege/content.read

Parameters:

  • successCallback: Callback method to be invoked when retrieving a list of all playlists completes
  • errorCallback [optional] [nullable]: Callback method to be invoked when an error occurs

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    • with error type SecurityError, if the application does not have the privilege to call this method.

Code example:

 var gPlaylists;

 function getPlaylistsFail(err) {
     console.log("getPlaylists failed: " + err);
 }

 function getPlaylistsSuccess(playlists) {
     var cur, i;
     gPlaylists = playlists;
     for(i = 0; i < gPlaylists.length; ++i) {
         cur = gPlaylists[i];
         console.log("[" + i + "] name:" + cur.name + " num tracks:" +
                 cur.numberOfTracks);
     }
 }

 tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail);
 
createPlaylist
Creates a new playlist.
void createPlaylist(DOMString name, PlaylistSuccessCallback successCallback, optional ErrorCallback? errorCallback, optional Playlist? sourcePlaylist);
             

Since: 2.3

The errorCallback is launched with these error types:

  • InvalidValuesError: If name is empty or is same as the name of an existing playlist
  • UnknownError: In case of any other error

Privilege level: public

Privilege: http://tizen.org/privilege/content.write

Parameters:

  • name: Name of the new playlist (case sensitive)
  • successCallback: Callback method to be invoked to provide a created playlist
  • errorCallback [optional] [nullable]: Callback method to be invoked when an error occurs
  • sourcePlaylist [optional] [nullable]: Optional existing playlist to clone

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    • with error type SecurityError, if the application does not have the privilege to call this method.

Code example:

 var gPlaylists;
 var gPlaylist;

 function getPlaylistsFail(err) {
     console.log("getPlaylists failed: " + err.message);
 }

 function getPlaylistsSuccess(playlists) {
     var cur, i;
     gPlaylists = playlists;
     for(i = 0; i < gPlaylists.length; ++i) {
         cur = gPlaylists[i];
         console.log("[" + i + "] name:" + cur.name + " num tracks:" +
                 cur.numberOfTracks);
     }
 }

 function findSuccess(contents) {
     if (contents.length > 0) {
         gPlaylist.add(contents[0]);
     }

     tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail);
 }

 function findFail(err) {
     console.log("find FAIL: " + err.message);
 }

 function createSuccess(playlist) {
     console.log("create SUCCESS");

     gPlaylist = playlist;
     tizen.content.find(findSuccess, findFail, null,
             new tizen.AttributeFilter("type", "EXACTLY", "AUDIO"));
 }

 function createFail(err) {
     console.log("create FAIL: " + err.message);
 }

 tizen.content.createPlaylist("My new playlist", createSuccess, createFail);

 
removePlaylist
Removes a playlist.
void removePlaylist(PlaylistId id, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
             

Since: 2.3

The errorCallback is launched with these error types:

  • UnknownError: In case of any error

Privilege level: public

Privilege: http://tizen.org/privilege/content.write

Parameters:

  • id: Identifier of a playlist to remove
  • successCallback [optional] [nullable]: Callback method to be invoked when removing a playlist completes
  • errorCallback [optional] [nullable]: Callback method to be invoked when an error occurs

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    • with error type SecurityError, if the application does not have the privilege to call this method.

Code example:

 var gPlaylists;

 function removePlaylistSuccess() {
     console.log("removePlaylist SUCCESS");
 }

 function removePlaylistFail(err) {
     console.log("removePlaylist FAIL: " + err);
 }

 function getPlaylistsFail(err) {
     console.log("getPlaylists failed: " + err);
 }

 function getPlaylistsSuccess(playlists) {
     var cur, i;
     gPlaylists = playlists;
     for(i = 0; i < gPlaylists.length; ++i) {
         cur = gPlaylists[i];
         console.log("[" + i + "] name:" + cur.name + " num tracks:" +
                 cur.numberOfTracks);
     }

     if(gPlaylists.length < 1) {
         console.log("Please add at least 1 playlist");
         return;
     }

     console.log("will remove playlist at index [0] name:"
             + gPlaylists[0].name);

     tizen.content.removePlaylist(gPlaylists[0].id, removePlaylistSuccess,
             removePlaylistFail);
 }

 tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail);

 
createThumbnail
Creates a content's thumbnail.
void createThumbnail(Content content, ThumbnailSuccessCallback successCallback, optional ErrorCallback? errorCallback);
             

Since: 3.0

The errorCallback is launched with these error types:

  • InvalidValuesError: In case of invalid content object.
  • AbortError: In case of any error.

Privilege level: public

Privilege: http://tizen.org/privilege/content.write

Parameters:

  • content: Content object for which a new thumbnail will be created
  • successCallback: Callback method to be invoked when the thumbnail is created
  • errorCallback [optional] [nullable]: Callback method to be invoked when an error occurs

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    • with error type SecurityError, if the application does not have the privilege to call this method.

Code example:

 function createCB(path) {
   console.log("The thumbnail path is " + path);
 }

 function findCB(contents) {
   if (contents.length > 0) {
     tizen.content.createThumbnail(contents[0], createCB);
   }
 }

 tizen.content.find(findCB);
 

Output example:

 The thumbnail path is /home/owner/share/media/.thumb/phone/.jpg-bed1d5f494830f7a52e1217f1e924aff.jpg
 

2.3. ContentArraySuccessCallback

The callback function used to return a list of content objects.
  [Callback=FunctionOnly, NoInterfaceObject] interface ContentArraySuccessCallback {
    void onsuccess(Content[] contents);
  };

Since: 2.0

Methods

onsuccess
Called when the list of content is retrieved successfully.
void onsuccess(Content[] contents);
             

Since: 2.0

Parameters:

  • contents: The array of Content objects.

2.4. ContentDirectoryArraySuccessCallback

The callback function used to return a list of ContentDirectory objects.
  [Callback=FunctionOnly, NoInterfaceObject] interface ContentDirectoryArraySuccessCallback {
    void onsuccess(ContentDirectory[] directories);
  };

Since: 2.0

Methods

onsuccess
Called when the directory list is retrieved successfully.
void onsuccess(ContentDirectory[] directories);
             

Since: 2.0

Parameters:

  • directories: The array of ContentDirectory objects.

2.5. ContentScanSuccessCallback

The callback function used to return content or content directory to scan.
  [Callback=FunctionOnly, NoInterfaceObject] interface ContentScanSuccessCallback {
    void onsuccess(DOMString uri);
  };

Since: 2.1

Methods

onsuccess
Called when the scanning has been completed.
void onsuccess(DOMString uri);
             

Since: 2.1

Remark : This callback is also invoked upon success of the scanDirectory() method since Tizen 2.4. Therefore, the uri parameter may now also be the URI of a ContentDirectory object.

Parameters:

2.6. ContentChangeCallback

This interface specifies a set of methods that are invoked every time a content change occurs.
  [Callback, NoInterfaceObject] interface ContentChangeCallback {
    void oncontentadded(Content content);

    void oncontentupdated(Content content);

    void oncontentremoved(ContentId id);

    void oncontentdiradded(ContentDirectory contentDir);

    void oncontentdirupdated(ContentDirectory contentDir);

    void oncontentdirremoved(ContentDirectoryId id);
  };

Since: 2.1

Methods

oncontentadded
Called when content is added.
void oncontentadded(Content content);
             

Since: 2.1

Parameters:

  • content: The content to add.
oncontentupdated
Called when content is updated.
void oncontentupdated(Content content);
             

Since: 2.1

Parameters:

  • content: The content to update.
oncontentremoved
Called when content is removed.
void oncontentremoved(ContentId id);
             

Since: 2.1

Parameters:

  • id: The ID of removed content.
oncontentdiradded
Called when a content directory is added.
void oncontentdiradded(ContentDirectory contentDir);
             

Since: 2.4

Parameters:

  • contentDir: The added content directory.
oncontentdirupdated
Called when a content directory is updated.
void oncontentdirupdated(ContentDirectory contentDir);
             

Since: 2.4

Parameters:

  • contentDir: The content directory혻after the update operation.
oncontentdirremoved
Called when a content directory is removed.
void oncontentdirremoved(ContentDirectoryId id);
             

Since: 2.4

Parameters:

  • id: The ID of removed content directory.

2.7. ContentDirectory

The ContentDirectory interface provides access to properties of a content directory.
  [NoInterfaceObject] interface ContentDirectory {

    readonly attribute ContentDirectoryId id;

    readonly attribute DOMString directoryURI;

    readonly attribute DOMString title;

    readonly attribute ContentDirectoryStorageType storageType;

    readonly attribute Date? modifiedDate;

   };

Since: 2.0

Attributes

  • readonly ContentDirectoryId id
    The opaque content directory identifier.

    Since: 2.0

  • readonly DOMString directoryURI
    The directory path on the device.

    Since: 2.0

  • readonly DOMString title
    The directory name.

    Since: 2.0

  • readonly ContentDirectoryStorageType storageType
    The type of device storage.

    Since: 2.0

  • readonly Date modifiedDate [nullable]
    The last modified date for a directory.

    Since: 2.0

2.8. Content

The Content interface provides access to the properties of a content item.
  [NoInterfaceObject] interface Content {

    readonly attribute DOMString[] editableAttributes;

    readonly attribute ContentId id;

    attribute DOMString name;

    readonly attribute ContentType type;

    readonly attribute DOMString mimeType;

    readonly attribute DOMString title;

    readonly attribute DOMString contentURI;

    readonly attribute DOMString[]? thumbnailURIs;

    readonly attribute Date? releaseDate;

    readonly attribute Date? modifiedDate;

    readonly attribute unsigned long size;

    attribute DOMString? description;

    attribute unsigned long rating;

    attribute boolean isFavorite;
  };

Since: 2.0

Attributes

  • readonly DOMString[] editableAttributes
    The list of attributes that are editable to the local backend using the update() or updateBatch() method.

    Since: 2.0

  • readonly ContentId id
    The opaque content identifier.

    Since: 2.0

  • DOMString name
    The content name. The initial value is the file name of the content.

    Since: 2.1

  • readonly ContentType type
    The content type.

    Since: 2.0

  • readonly DOMString mimeType
    The content MIME type.

    Since: 2.0

  • readonly DOMString title
    The content title.

    Since: 2.0

  • readonly DOMString contentURI
    The URI to access the content.

    Since: 2.0

  • readonly DOMString[] thumbnailURIs [nullable]
    The array of content thumbnail URIs.

    Since: 2.0

  • readonly Date releaseDate [nullable]
    The date when content has been released publicly. If only the release year is known, then the month and date are set to January and 1st respectively.

    Since: 2.0

  • readonly Date modifiedDate [nullable]
    The last modified date for a content item.

    Since: 2.0

  • readonly unsigned long size
    The file size of the content in bytes.

    Since: 2.0

  • DOMString description [nullable]
    The content description.

    Since: 2.0

  • unsigned long rating
    The content rating. This value can range from 0 to 10.

    Since: 2.0

  • boolean isFavorite
    Boolean value that indicates whether a content item is marked as a favorite.

    Since: 2.3

2.9. VideoContent

The VideoContent interface extends a basic Content object with video-specific attributes.
  [NoInterfaceObject] interface VideoContent : Content {

    attribute SimpleCoordinates? geolocation;

    readonly attribute DOMString? album;

    readonly attribute DOMString[]? artists;

    readonly attribute unsigned long duration;

    readonly attribute unsigned long width;

    readonly attribute unsigned long height;

  };

Since: 2.0

Attributes

  • SimpleCoordinates geolocation [nullable]
    The geographical location where the video has been made.

    Since: 2.0

  • readonly DOMString album [nullable]
    The album name to which the video belongs.

    Since: 2.0

  • readonly DOMString[] artists [nullable]
    The list of artists who created the video.

    Since: 2.0

  • readonly unsigned long duration
    The video duration in milliseconds.

    Since: 2.0

  • readonly unsigned long width
    The width of a video in pixels.

    Since: 2.0

  • readonly unsigned long height
    The height of the video in pixels.

    Since: 2.0

2.10. AudioContentLyrics

The AudioContentLyrics interface provides lyrics for music.
  [NoInterfaceObject] interface AudioContentLyrics {

    readonly attribute AudioContentLyricsType type;

    readonly attribute unsigned long[] timestamps;

    readonly attribute DOMString[] texts;
  };

Since: 2.0

Attributes

  • readonly AudioContentLyricsType type
    The type of lyrics, that is, whether they are synchronized with the music.

    Since: 2.0

  • readonly unsigned long[] timestamps
    The array of timestamps in milliseconds for lyrics.

    If the lyrics are not synchronized (if there is no time information for the lyrics) the array is undefined.

    Since: 2.0

  • readonly DOMString[] texts
    The array of lyrics snippets.

    If the lyrics are not synchronized, the array has only one member with full lyrics.

    Since: 2.0

2.11. AudioContent

The AudioContent interface extends a basic Content object with audio-specific attributes.
  [NoInterfaceObject] interface AudioContent : Content {

    readonly attribute DOMString? album;

    readonly attribute DOMString[]? genres;

    readonly attribute DOMString[]? artists;

    readonly attribute DOMString[]? composers;

    readonly attribute AudioContentLyrics? lyrics;

    readonly attribute DOMString? copyright;

    readonly attribute unsigned long bitrate;

    readonly attribute unsigned short? trackNumber;

    readonly attribute unsigned long duration;

  };

Since: 2.0

Attributes

  • readonly DOMString album [nullable]
    The album name to which the audio belongs.

    Since: 2.0

  • readonly DOMString[] genres [nullable]
    The list of genres to which the audio belongs.

    Since: 2.0

  • readonly DOMString[] artists [nullable]
    The list of artists who created the audio.

    Since: 2.0

  • readonly DOMString[] composers [nullable]
    The list of composers for the music.

    Since: 2.0

  • readonly AudioContentLyrics lyrics [nullable]
    The lyrics of a song in an audio file.

    Since: 2.0

  • readonly DOMString copyright [nullable]
    The copyright information.

    Since: 2.0

  • readonly unsigned long bitrate
    The audio bitrate in bits per second. By default, this value is 0.

    Since: 2.0

  • readonly unsigned short trackNumber [nullable]
    The track number if the audio belongs to an album.

    Since: 2.0

  • readonly unsigned long duration
    The audio duration in milliseconds.

    Since: 2.0

2.12. ImageContent

The ImageContent interface extends a basic Content object with image-specific attributes.
  [NoInterfaceObject] interface ImageContent : Content {

    attribute SimpleCoordinates? geolocation;

    readonly attribute unsigned long width;

    readonly attribute unsigned long height;

    attribute ImageContentOrientation orientation;
  };

Since: 2.0

Attributes

  • SimpleCoordinates geolocation [nullable]
    The geographical location where the image has been made.

    Since: 2.0

  • readonly unsigned long width
    The width of an image in pixels.

    Since: 2.0

  • readonly unsigned long height
    The height of an image in pixels.

    Since: 2.0

  • ImageContentOrientation orientation
    The image orientation.

    Since: 2.0

2.13. PlaylistItem

The PlaylistItem interface represents a playlist item.
  [NoInterfaceObject]
  interface PlaylistItem {
    readonly attribute Content content;
  };

Since: 2.3

Attributes

  • readonly Content content
    Content contained in this playlist item.

    Since: 2.3

2.14. Playlist

The Playlist interface represents a playlist.
  [NoInterfaceObject]
  interface Playlist {
    readonly attribute PlaylistId id;

    attribute DOMString name raises(WebAPIException);

    readonly attribute long numberOfTracks;

    attribute DOMString? thumbnailURI raises(WebAPIException);

    void add(Content item) raises(WebAPIException);

    void addBatch(Content[] items,
                  optional SuccessCallback? successCallback,
                  optional ErrorCallback? errorCallback) raises(WebAPIException);

    void remove(PlaylistItem item) raises(WebAPIException);

    void removeBatch(PlaylistItem[] items,
                     optional SuccessCallback? successCallback,
                     optional ErrorCallback? errorCallback) raises(WebAPIException);

    void get(PlaylistItemArraySuccessCallback successCallback,
             optional ErrorCallback? errorCallback,
             optional long? count,
             optional long? offset) raises(WebAPIException);

    void setOrder(PlaylistItem[] items,
            optional SuccessCallback? successCallback,
            optional ErrorCallback? errorCallback) raises(WebAPIException);

    void move(PlaylistItem item,
              long delta,
              optional SuccessCallback? successCallback,
              optional ErrorCallback? errorCallback) raises(WebAPIException);
  };

Since: 2.3

Attributes

  • readonly PlaylistId id
    Identifier of a playlist.

    Since: 2.3

  • DOMString name
    Name of a playlist (case sensitive and unique).

    When name is set, the change is recorded in the database.

    Since: 2.3

    Privilege level: public

    Privilege: http://tizen.org/privilege/content.write

    Exceptions:

    • WebAPIException
      • with error type InvalidValuesError, when assigning an invalid value (e.g. playlist of the same name already exists).

      • with error type SecurityError, if the application does not have the privilege to change this attribute.

  • readonly long numberOfTracks
    Number of playlist items in the playlist.

    Since: 2.3

  • DOMString thumbnailURI [nullable]
    Thumbnail URI of a playlist.

    By default, this attribute is set to null.
    When thumbnailURI is set, the change is recorded in the database.

    Since: 2.3

    Privilege level: public

    Privilege: http://tizen.org/privilege/content.write

    Exceptions:

    • WebAPIException
      • with error type InvalidValuesError, when assigning an invalid value (e.g. if the URI does not start with "file:///").

      • with error type SecurityError, if the application does not have the privilege to change this attribute.

Methods

add
Adds a content item to a playlist.
void add(Content item);
             

Since: 2.3

See code example for the createPlaylist() method.

Privilege level: public

Privilege: http://tizen.org/privilege/content.write

Parameters:

  • item: Content to add

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    • with error type SecurityError, if the application does not have the privilege to call this method.

    • with error type UnknownError, if any other error occurs.

addBatch
Adds tracks to a playlist as a batch, asynchronously.
void addBatch(Content[] items, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
             

Since: 2.3

The errorCallback is launched with these error types:

  • UnknownError: In case of any error

Privilege level: public

Privilege: http://tizen.org/privilege/content.write

Parameters:

  • items: List of tracks (Content objects) to add
  • successCallback [optional] [nullable]: Callback method to be invoked when adding a list of content items to a playlist completes successfully
  • errorCallback [optional] [nullable]: Callback method to be invoked when an error occurs

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    • with error type SecurityError, if the application does not have the privilege to call this method.

remove
Removes a track from a playlist.
void remove(PlaylistItem item);
             

Since: 2.3

Privilege level: public

Privilege: http://tizen.org/privilege/content.write

Parameters:

  • item: Playlist item to remove

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    • with error type SecurityError, if the application does not have the privilege to call this method.

    • with error type UnknownError, if any other error occurs.

Code example:

 var gPlaylists, gItems, gCurPlaylist;

 function get2Fail(err) {
     console.log("get items (after remove) failed: " + err);
 }

 function get2Success(items) {
    console.log("Playlist items:");
    for(var i = 0; i < items.length ; ++i) {
        console.log("[" + i + "]: name:" + items[i].content.name);
    }
 }

 function getSuccess(items) {
    gItems = items;

    if(gItems.length < 1) {
        console.log("Please add at least 1 tracks to playlist!");
        return;
    }

    console.log("Original playlist:");
    for(var i = 0; i < gItems.length ; ++i) {
        console.log("[" + i + "]: name:" + gItems[i].content.name);
    }

    console.log("Will remove item at index [0] name:" + gItems[0].content.name);
    gCurPlaylist.remove(gItems[0]);
    gCurPlaylist.get(get2Success, get2Fail);
 }

 function getFail(err) {
     console.log("get items failed: " + err);
 }

 function getPlaylistsFail(err) {
     console.log("getPlaylists failed: " + err);
 }

 function getPlaylistsSuccess(playlists) {
     gPlaylists = playlists;
     if(gPlaylists.length === 0) {
         console.log("Please create at least 1 playlist!");
         return;
     }

     gCurPlaylist = gPlaylists[0];
     gCurPlaylist.get(getSuccess, getFail);
 }

 tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail);

 
removeBatch
Removes tracks from a playlist as a batch, asynchronously.
void removeBatch(PlaylistItem[] items, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
             

Since: 2.3

The errorCallback is launched with these error types:

  • UnknownError: In case of any other error

Privilege level: public

Privilege: http://tizen.org/privilege/content.write

Parameters:

  • items: List of tracks to remove
  • successCallback [optional] [nullable]: Callback method to be invoked when removing a list of content items from a playlist completes successfully
  • errorCallback [optional] [nullable]: Callback method to be invoked when an error occurs

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    • with error type SecurityError, if the application does not have the privilege to call this method.

Code example:

 var gPlaylists, gItems, gCurPlaylist;

 function get2Fail(err) {
     console.log("get items (after remove batch) failed: " + err);
 }

 function get2Success(items) {
    console.log("Playlist after remove batch:");
    for(var i = 0; i < items.length ; ++i) {
        console.log("[" + i + "]: name:" + items[i].content.name);
    }
 }

 function removeBatchSuccess() {
     console.log("removeBatch success");
     gCurPlaylist.get(get2Success, get2Fail);
 }

 function removeBatchFail(err) {
     console.log("removeBatch failed: " + err);
 }

 function getSuccess(items) {
    gItems = items;

    if(gItems.length < 4) {
        console.log("Please add at least 4 tracks to playlist!");
        return;
    }

    console.log("Original playlist:");
    for(var i = 0; i < gItems.length ; ++i) {
        console.log("[" + i + "]: name:" + gItems[i].content.name);
    }

    console.log("Will remove items at index [0](name:" + gItems[0].content.name
            + ") and at index [2](name:" + gItems[2].content.name + ")");
    gCurPlaylist.removeBatch([gItems[2], gItems[0]],
            removeBatchSuccess, removeBatchFail);
 }

 function getFail(err) {
     console.log("get items failed: " + err);
 }

 function getPlaylistsFail(err) {
     console.log("getPlaylists failed: " + err);
 }

 function getPlaylistsSuccess(playlists) {
     gPlaylists = playlists;
     if(gPlaylists.length === 0) {
         console.log("Please create at least 1 playlist!");
         return;
     }

     gCurPlaylist = gPlaylists[0];
     gCurPlaylist.get(getSuccess, getFail);
 }

 tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail);

 
get
Gets playlist items from a playlist.
void get(PlaylistItemArraySuccessCallback successCallback, optional ErrorCallback? errorCallback, optional long? count, optional long? offset);
             

Since: 2.3

The errorCallback is launched with these error types:

  • InvalidValuesError: If any of the input parameters contain an invalid value (e.g count or offset is a negative number)
  • UnknownError: In case of any error

Privilege level: public

Privilege: http://tizen.org/privilege/content.read

Parameters:

  • successCallback: Callback method to be invoked for a list of tracks in the playlist
  • errorCallback [optional] [nullable]: Callback method to be invoked when an error occurs
  • count [optional] [nullable]: Number of playlist items to return
    If the count is not passed, all playlist items are retrieved.
  • offset [optional] [nullable]: Offset of the track from the beginning of the playlist
    The default value is 0
    It means no offset.

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    • with error type SecurityError, if the application does not have the privilege to call this method.

Code example:

 var gPlaylists, gItems, gCurPlaylist;

 function getSuccess(items) {
     gItems = items;
     console.log("Playlist items:");
     for(var i = 0; i < items.length ; ++i) {
         console.log("[" + i + "]: name:" + items[i].name);
     }
 }

 function getFail(err) {
     console.log("get items failed: " + err);
 }

 function getPlaylistsFail(err) {
     console.log("getPlaylists failed: " + err);
 }

 function getPlaylistsSuccess(playlists) {
     gPlaylists = playlists;
     if(gPlaylists.length === 0) {
         console.log("Please create at least 1 playlist!");
         return;
     }

     gCurPlaylist = gPlaylists[0];
     // To retrieves all playlist items of 'gCurPlaylist' playlist.
     gCurPlaylist.get(getSuccess, getFail);
 }

 tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail);
 
setOrder
Changes the play order of all playlist items in the playlist.
void setOrder(PlaylistItem[] items, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
             

Since: 2.3

The errorCallback is launched with these error types:

  • InvalidValuesError: In case the item in the passed items array is not inside this playlist, or the items array does not contain all items from the playlist
  • UnknownError: In case of any other error

Privilege level: public

Privilege: http://tizen.org/privilege/content.write

Parameters:

  • items: List of playlist items to set in play order
    This list must include all playlist items of this playlist
    If not, InvalidValuesError is thrown.
  • successCallback [optional] [nullable]: Callback method to be invoked when changing the positions of items in the playlist is successfully completed
  • errorCallback [optional] [nullable]: Callback method to be invoked when an error occurs

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.

    • with error type SecurityError, if the application does not have the privilege to call this method.

Code example:

 var gPlaylists, gItems, gCurPlaylist, gExpectedOrder;

 function get2Fail(err) {
     console.log("get items (after set order) failed: " + err);
 }

 function get2Success(items) {
    console.log("Playlist order after setOrder:");
    for(var i = 0; i < items.length ; ++i) {
        console.log("[" + i + "]: name:" + items[i].content.name);
    }
 }

 function setOrderSuccess() {
     console.log("set items order SUCCESS");
     gCurPlaylist.get(get2Success, get2Fail);
 }

 function setOrderFail(err) {
     console.log("set items order failed: " + err);
 }

 function getSuccess(items) {
    gItems = items;

    if(gItems.length < 2) {
        console.log("Please add at least 2 tracks to playlist!");
        return;
    }

    console.log("Original order:");
    for(var i = 0; i < gItems.length ; ++i) {
        console.log("[" + i + "]: name:" + gItems[i].content.name);
    }

    gExpectedOrder = gItems.slice(0);
    gExpectedOrder.reverse();

    console.log("New order:");
    for(var i = 0; i < gExpectedOrder.length ; ++i) {
        console.log("[" + i + "]: name:" + gExpectedOrder[i].content.name);
    }

    gCurPlaylist.setOrder(gExpectedOrder, setOrderSuccess, setOrderFail);
 }

 function getFail(err) {
     console.log("get items failed: " + err);
 }

 function getPlaylistsFail(err) {
     console.log("getPlaylists failed: " + err);
 }

 function getPlaylistsSuccess(playlists) {
     gPlaylists = playlists;
     if(gPlaylists.length === 0) {
         console.log("Please create at least 1 playlist!");
         return;
     }

     gCurPlaylist = gPlaylists[0];
     gCurPlaylist.get(getSuccess, getFail);
 }

 tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail);

 
move
Moves the specified item up or down a specified amount in the play order.
void move(PlaylistItem item, long delta, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
             

Since: 2.3

If current index + delta is:

  • < 0 then the item is moved to the first position in the playlist
  • ??number of tracks then the item is moved to the last position in the playlist

The errorCallback is launched with these error types:

  • InvalidValuesError: In case the item in the passed items array is not inside this playlist or some item of this playlist is not included in items
  • UnknownError: In case of any other error

Privilege level: public

Privilege: http://tizen.org/privilege/content.write

Parameters:

  • item: Playlist item to move
  • delta: How many positions to move the item, negative value means move up, positive means move down
  • successCallback [optional] [nullable]: Callback method to be invoked when the playlist item has successfully been moved
  • errorCallback [optional] [nullable]: Callback method to be invoked when an error occurs

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    • with error type SecurityError, if the application does not have the privilege to call this method.

Code example:

 var gPlaylists, gItems, gCurPlaylist;

 function get2Fail(err) {
     console.log("get items (after move item) failed: " + err);
 }

 function get2Success(items) {
    console.log("Playlist order after move:");
    for(var i = 0; i < items.length ; ++i) {
        console.log("[" + i + "]: name:" + items[i].content.name);
    }
 }

 function moveSuccess() {
     console.log("move item SUCCESS");
     gCurPlaylist.get(get2Success, get2Fail);
 }

 function moveFail(err) {
     console.log("move item failed: " + err);
 }

 function getSuccess(items) {
    gItems = items;

    if(gItems.length < 2) {
        console.log("Please add at least 2 tracks to playlist!");
        return;
    }

    console.log("Original order:");
    for(var i = 0; i < gItems.length ; ++i) {
        console.log("[" + i + "]: name:" + gItems[i].content.name);
    }

    console.log("Will move item at index [1] (name: " +
            gItems[1].content.name + ") up by one place (to [0])");

    gCurPlaylist.move(gItems[1], -1, moveSuccess, moveFail);
    gItems.unshift(gItems.splice(1, 1)[0]);
 }

 function getFail(err) {
     console.log("get items failed: " + err);
 }

 function getPlaylistsFail(err) {
     console.log("getPlaylists failed: " + err);
 }

 function getPlaylistsSuccess(playlists) {
     gPlaylists = playlists;
     if(gPlaylists.length === 0) {
         console.log("Please create at least 1 playlist!");
         return;
     }

     gCurPlaylist = gPlaylists[0];
     gCurPlaylist.get(getSuccess, getFail);
 }

 tizen.content.getPlaylists(getPlaylistsSuccess, getPlaylistsFail);
 

2.15. PlaylistArraySuccessCallback

The PlaylistArraySuccessCallback interface specifies a success callback that is invoked when all existing playlists are retrieved successfully.
  [Callback=FunctionOnly, NoInterfaceObject] interface PlaylistArraySuccessCallback {
    void onsuccess(Playlist[] playlists);
  };

Since: 2.3

It is used in tizen.content.getPlaylists().

Methods

onsuccess
Called when the tizen.content.getPlaylists() method completes successfully.
void onsuccess(Playlist[] playlists);
             

Since: 2.3

Parameters:

  • playlists: List of all playlists on a device

2.16. PlaylistSuccessCallback

The PlaylistSuccessCallback interface specifies a success callback that is invoked when a new playlist is successfully created.
  [Callback=FunctionOnly, NoInterfaceObject] interface PlaylistSuccessCallback {
    void onsuccess(Playlist playlist);
  };

Since: 2.3

It is used in tizen.content.createPlaylist().

Methods

onsuccess
Called when the tizen.content.createPlaylist() method completes successfully.
void onsuccess(Playlist playlist);
             

Since: 2.3

Parameters:

  • playlist: Newly created playlist

2.17. PlaylistItemArraySuccessCallback

The PlaylistItemArraySuccessCallback interface specifies a success callback that is invoked when a list of playlist items are successfully retrieved.
  [Callback=FunctionOnly, NoInterfaceObject] interface PlaylistItemArraySuccessCallback {
    void onsuccess(PlaylistItem[] items);
  };

Since: 2.3

Methods

onsuccess
Called when the playlist.get() method completes successfully.
void onsuccess(PlaylistItem[] items);
             

Since: 2.3

Parameters:

  • items: List of playlist items

2.18. ThumbnailSuccessCallback

The ThumbnailSuccessCallback interface specifies a success callback that is invoked when a content's thumbnail is successfully created.
  [Callback=FunctionOnly, NoInterfaceObject] interface ThumbnailSuccessCallback {
    void onsuccess(DOMString path);
  };

Since: 3.0

Methods

onsuccess
Called when the tizen.content.createThumbnail() method completes successfully.
void onsuccess(DOMString path);
             

Since: 3.0

Parameters:

  • path: Path of the created thumbnail

3. Full WebIDL

module Content {

  enum ContentDirectoryStorageType { "INTERNAL", "EXTERNAL" };

  enum ContentType { "IMAGE", "VIDEO", "AUDIO", "OTHER" };

  enum AudioContentLyricsType { "SYNCHRONIZED", "UNSYNCHRONIZED" };

  enum ImageContentOrientation { "NORMAL", "FLIP_HORIZONTAL", "ROTATE_180", "FLIP_VERTICAL", "TRANSPOSE", "ROTATE_90", "TRANSVERSE", "ROTATE_270" };

  typedef DOMString ContentId;

  typedef DOMString ContentDirectoryId;

  typedef DOMString PlaylistId;

  [NoInterfaceObject] interface ContentManagerObject {
    readonly attribute ContentManager content;
  };
  Tizen implements ContentManagerObject;

  [NoInterfaceObject] interface ContentManager {

    void update(Content content) raises(WebAPIException);

    void updateBatch(Content[] contents,
                     optional SuccessCallback? successCallback,
                     optional ErrorCallback? errorCallback) raises(WebAPIException);

    void getDirectories(ContentDirectoryArraySuccessCallback successCallback,
                        optional ErrorCallback? errorCallback) raises(WebAPIException);

    void find(ContentArraySuccessCallback successCallback,
              optional ErrorCallback? errorCallback,
              optional ContentDirectoryId? directoryId,
              optional AbstractFilter? filter,
              optional SortMode? sortMode,
              optional unsigned long? count,
              optional unsigned long? offset) raises(WebAPIException);


    void scanFile(DOMString contentURI,
                  optional ContentScanSuccessCallback? successCallback,
                  optional ErrorCallback? errorCallback) raises(WebAPIException);

    void scanDirectory(DOMString contentDirURI,
                       boolean recursive,
                       optional ContentScanSuccessCallback? successCallback,
                       optional ErrorCallback? errorCallback) raises(WebAPIException);

    void cancelScanDirectory(DOMString contentDirURI) raises(WebAPIException);

    long addChangeListener(ContentChangeCallback changeCallback) raises(WebAPIException);

    void removeChangeListener(long listenerId) raises(WebAPIException);

    void setChangeListener(ContentChangeCallback changeCallback) raises(WebAPIException);

    void unsetChangeListener() raises(WebAPIException);

    void getPlaylists(PlaylistArraySuccessCallback successCallback,
                      optional ErrorCallback? errorCallback) raises(WebAPIException);

    void createPlaylist(DOMString name,
                        PlaylistSuccessCallback successCallback,
                        optional ErrorCallback? errorCallback,
                        optional Playlist? sourcePlaylist) raises(WebAPIException);

    void removePlaylist(PlaylistId id,
                        optional SuccessCallback? successCallback,
                        optional ErrorCallback? errorCallback) raises(WebAPIException);

    void createThumbnail(Content content,
                         ThumbnailSuccessCallback successCallback,
                         optional ErrorCallback? errorCallback) raises(WebAPIException);
  };

  [Callback=FunctionOnly, NoInterfaceObject] interface ContentArraySuccessCallback {
    void onsuccess(Content[] contents);
  };

  [Callback=FunctionOnly, NoInterfaceObject] interface ContentDirectoryArraySuccessCallback {
    void onsuccess(ContentDirectory[] directories);
  };

  [Callback=FunctionOnly, NoInterfaceObject] interface ContentScanSuccessCallback {
    void onsuccess(DOMString uri);
  };

  [Callback, NoInterfaceObject] interface ContentChangeCallback {
    void oncontentadded(Content content);

    void oncontentupdated(Content content);

    void oncontentremoved(ContentId id);

    void oncontentdiradded(ContentDirectory contentDir);

    void oncontentdirupdated(ContentDirectory contentDir);

    void oncontentdirremoved(ContentDirectoryId id);
  };


  [NoInterfaceObject] interface ContentDirectory {

    readonly attribute ContentDirectoryId id;

    readonly attribute DOMString directoryURI;

    readonly attribute DOMString title;

    readonly attribute ContentDirectoryStorageType storageType;

    readonly attribute Date? modifiedDate;

   };

  [NoInterfaceObject] interface Content {

    readonly attribute DOMString[] editableAttributes;

    readonly attribute ContentId id;

    attribute DOMString name;

    readonly attribute ContentType type;

    readonly attribute DOMString mimeType;

    readonly attribute DOMString title;

    readonly attribute DOMString contentURI;

    readonly attribute DOMString[]? thumbnailURIs;

    readonly attribute Date? releaseDate;

    readonly attribute Date? modifiedDate;

    readonly attribute unsigned long size;

    attribute DOMString? description;

    attribute unsigned long rating;

    attribute boolean isFavorite;
  };

  [NoInterfaceObject] interface VideoContent : Content {

    attribute SimpleCoordinates? geolocation;

    readonly attribute DOMString? album;

    readonly attribute DOMString[]? artists;

    readonly attribute unsigned long duration;

    readonly attribute unsigned long width;

    readonly attribute unsigned long height;

  };


  [NoInterfaceObject] interface AudioContentLyrics {

    readonly attribute AudioContentLyricsType type;

    readonly attribute unsigned long[] timestamps;

    readonly attribute DOMString[] texts;
  };

  [NoInterfaceObject] interface AudioContent : Content {

    readonly attribute DOMString? album;

    readonly attribute DOMString[]? genres;

    readonly attribute DOMString[]? artists;

    readonly attribute DOMString[]? composers;

    readonly attribute AudioContentLyrics? lyrics;

    readonly attribute DOMString? copyright;

    readonly attribute unsigned long bitrate;

    readonly attribute unsigned short? trackNumber;

    readonly attribute unsigned long duration;

  };

  [NoInterfaceObject] interface ImageContent : Content {

    attribute SimpleCoordinates? geolocation;

    readonly attribute unsigned long width;

    readonly attribute unsigned long height;

    attribute ImageContentOrientation orientation;
  };

  [NoInterfaceObject]
  interface PlaylistItem {
    readonly attribute Content content;
  };

  [NoInterfaceObject]
  interface Playlist {
    readonly attribute PlaylistId id;

    attribute DOMString name raises(WebAPIException);

    readonly attribute long numberOfTracks;

    attribute DOMString? thumbnailURI raises(WebAPIException);

    void add(Content item) raises(WebAPIException);

    void addBatch(Content[] items,
                  optional SuccessCallback? successCallback,
                  optional ErrorCallback? errorCallback) raises(WebAPIException);

    void remove(PlaylistItem item) raises(WebAPIException);

    void removeBatch(PlaylistItem[] items,
                     optional SuccessCallback? successCallback,
                     optional ErrorCallback? errorCallback) raises(WebAPIException);

    void get(PlaylistItemArraySuccessCallback successCallback,
             optional ErrorCallback? errorCallback,
             optional long? count,
             optional long? offset) raises(WebAPIException);

    void setOrder(PlaylistItem[] items,
            optional SuccessCallback? successCallback,
            optional ErrorCallback? errorCallback) raises(WebAPIException);

    void move(PlaylistItem item,
              long delta,
              optional SuccessCallback? successCallback,
              optional ErrorCallback? errorCallback) raises(WebAPIException);
  };

  [Callback=FunctionOnly, NoInterfaceObject] interface PlaylistArraySuccessCallback {
    void onsuccess(Playlist[] playlists);
  };

  [Callback=FunctionOnly, NoInterfaceObject] interface PlaylistSuccessCallback {
    void onsuccess(Playlist playlist);
  };

  [Callback=FunctionOnly, NoInterfaceObject] interface PlaylistItemArraySuccessCallback {
    void onsuccess(PlaylistItem[] items);
  };

  [Callback=FunctionOnly, NoInterfaceObject] interface ThumbnailSuccessCallback {
    void onsuccess(DOMString path);
  };
};