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.4.
Since: 2.4
Interface | Method |
---|---|
ContentManagerObject | |
ContentManager |
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)
long addChangeListener (ContentChangeCallback changeCallback)
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 | |
ContentDirectoryArraySuccessCallback | void onsuccess (ContentDirectory[] directories) |
ContentScanSuccessCallback | void onsuccess (DOMString uri) |
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)
|
ContentDirectory | |
Content | |
VideoContent | |
AudioContentLyrics | |
AudioContent | |
ImageContent | |
PlaylistItem | |
Playlist |
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 | |
PlaylistSuccessCallback | |
PlaylistItemArraySuccessCallback | void onsuccess (PlaylistItem[] items) |
ThumbnailSuccessCallback | void onsuccess (DOMString path) |
enum ContentDirectoryStorageType { "INTERNAL", "EXTERNAL" };
Since: 2.4
Defines whether a content directory is stored on internal or external storage (such as a removable memory card).
enum ContentType { "IMAGE", "VIDEO", "AUDIO", "OTHER" };
Since: 2.4
Defines the type of content such as an image, video, audio, or any other.
Remark: "OTHER" type is added since Tizen 2.4 and since 4.0 it is optional type, related to http://tizen.org/feature/content.scanning.others feature. One can check "OTHER" type support using systeminfo API with tizen.systeminfo.getCapability("http://tizen.org/feature/content.scanning.others").
enum AudioContentLyricsType { "SYNCHRONIZED", "UNSYNCHRONIZED" };
Since: 2.4
Defines whether the lyrics supplied with an audio file is time-synchronized.
enum ImageContentOrientation { "NORMAL", "FLIP_HORIZONTAL", "ROTATE_180", "FLIP_VERTICAL", "TRANSPOSE", "ROTATE_90", "TRANSVERSE", "ROTATE_270" };
Since: 2.4
Defines the orientation of an image.
[NoInterfaceObject] interface ContentManagerObject {
readonly attribute ContentManager content;
};
Tizen implements ContentManagerObject;
Since: 2.4
The tizen.content object allows accessing the functionality of the Content module.
[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 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.4
update
void update(Content content);
Since: 2.4
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:
Exceptions:
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
void updateBatch(Content[] contents, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 2.4
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:
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:
Exceptions:
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
void getDirectories(ContentDirectoryArraySuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.4
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:
Parameters:
Exceptions:
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
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.4
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:
Privilege level: public
Privilege: http://tizen.org/privilege/content.read
Parameters:
Exceptions:
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
void scanFile(DOMString contentURI, optional ContentScanSuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 2.4
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:
Privilege level: public
Privilege: http://tizen.org/privilege/content.write
Parameters:
Exceptions:
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
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:
Privilege level: public
Privilege: http://tizen.org/privilege/content.write
Parameters:
Exceptions:
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
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:
Exceptions:
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
long addChangeListener(ContentChangeCallback changeCallback);
Since: 3.0
Parameters:
Return value:
long Identifier of the newly added listener.Exceptions:
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
void removeChangeListener(long listenerId);
Since: 3.0
Parameters:
Exceptions:
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
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.4
Privilege level: public
Privilege: http://tizen.org/privilege/content.read
Parameters:
Exceptions:
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
Deprecated. Deprecated since 3.0. Instead, use removeChangeListener().
void unsetChangeListener();
Since: 2.4
Privilege level: public
Privilege: http://tizen.org/privilege/content.read
Exceptions:
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
void getPlaylists(PlaylistArraySuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.4
The errorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/content.read
Parameters:
Exceptions:
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
void createPlaylist(DOMString name, PlaylistSuccessCallback successCallback, optional ErrorCallback? errorCallback, optional Playlist? sourcePlaylist);
Since: 2.4
The errorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/content.write
Parameters:
Exceptions:
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
void removePlaylist(PlaylistId id, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 2.4
The errorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/content.write
Parameters:
Exceptions:
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
void createThumbnail(Content content, ThumbnailSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 3.0
The errorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/content.write
Parameters:
Exceptions:
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
[Callback=FunctionOnly, NoInterfaceObject] interface ContentArraySuccessCallback {
void onsuccess(Content[] contents);
};
Since: 2.4
onsuccess
void onsuccess(Content[] contents);
Since: 2.4
Parameters:
[Callback=FunctionOnly, NoInterfaceObject] interface ContentDirectoryArraySuccessCallback {
void onsuccess(ContentDirectory[] directories);
};
Since: 2.4
onsuccess
void onsuccess(ContentDirectory[] directories);
Since: 2.4
Parameters:
[Callback=FunctionOnly, NoInterfaceObject] interface ContentScanSuccessCallback {
void onsuccess(DOMString uri);
};
Since: 2.4
onsuccess
void onsuccess(DOMString uri);
Since: 2.4
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:
[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.4
oncontentadded
void oncontentadded(Content content);
Since: 2.4
Parameters:
oncontentupdated
void oncontentupdated(Content content);
Since: 2.4
Parameters:
oncontentremoved
void oncontentremoved(ContentId id);
Since: 2.4
Parameters:
oncontentdiradded
void oncontentdiradded(ContentDirectory contentDir);
Since: 2.4
Parameters:
oncontentdirupdated
void oncontentdirupdated(ContentDirectory contentDir);
Since: 2.4
Parameters:
oncontentdirremoved
void oncontentdirremoved(ContentDirectoryId id);
Since: 2.4
Parameters:
[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.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
[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.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
[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.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
[NoInterfaceObject] interface AudioContentLyrics {
readonly attribute AudioContentLyricsType type;
readonly attribute unsigned long[] timestamps;
readonly attribute DOMString[] texts;
};
Since: 2.4
Since: 2.4
If the lyrics are not synchronized (if there is no time information for the lyrics) the array is undefined.
Since: 2.4
If the lyrics are not synchronized, the array has only one member with full lyrics.
Since: 2.4
[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.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
[NoInterfaceObject] interface ImageContent : Content {
attribute SimpleCoordinates? geolocation;
readonly attribute unsigned long width;
readonly attribute unsigned long height;
attribute ImageContentOrientation orientation;
};
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
[NoInterfaceObject]
interface PlaylistItem {
readonly attribute Content content;
};
Since: 2.4
Since: 2.4
[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.4
Since: 2.4
When name is set, the change is recorded in the database.
Since: 2.4
Privilege level: public
Privilege: http://tizen.org/privilege/content.write
Exceptions:
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.
Since: 2.4
By default, this attribute is set to null.
When thumbnailURI is set, the change is recorded in the database.
Since: 2.4
Privilege level: public
Privilege: http://tizen.org/privilege/content.write
Exceptions:
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.
add
void add(Content item);
Since: 2.4
See code example for the createPlaylist() method.
Privilege level: public
Privilege: http://tizen.org/privilege/content.write
Parameters:
Exceptions:
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
void addBatch(Content[] items, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 2.4
The errorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/content.write
Parameters:
Exceptions:
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
void remove(PlaylistItem item);
Since: 2.4
Privilege level: public
Privilege: http://tizen.org/privilege/content.write
Parameters:
Exceptions:
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
void removeBatch(PlaylistItem[] items, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 2.4
The errorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/content.write
Parameters:
Exceptions:
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
void get(PlaylistItemArraySuccessCallback successCallback, optional ErrorCallback? errorCallback, optional long? count, optional long? offset);
Since: 2.4
The errorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/content.read
Parameters:
Exceptions:
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
void setOrder(PlaylistItem[] items, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 2.4
The errorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/content.write
Parameters:
Exceptions:
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
void move(PlaylistItem item, long delta, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 2.4
If current index + delta is:
The errorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/content.write
Parameters:
Exceptions:
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);
[Callback=FunctionOnly, NoInterfaceObject] interface PlaylistArraySuccessCallback {
void onsuccess(Playlist[] playlists);
};
Since: 2.4
It is used in tizen.content.getPlaylists().
onsuccess
void onsuccess(Playlist[] playlists);
Since: 2.4
Parameters:
[Callback=FunctionOnly, NoInterfaceObject] interface PlaylistSuccessCallback {
void onsuccess(Playlist playlist);
};
Since: 2.4
It is used in tizen.content.createPlaylist().
onsuccess
void onsuccess(Playlist playlist);
Since: 2.4
Parameters:
[Callback=FunctionOnly, NoInterfaceObject] interface PlaylistItemArraySuccessCallback {
void onsuccess(PlaylistItem[] items);
};
Since: 2.4
onsuccess
void onsuccess(PlaylistItem[] items);
Since: 2.4
Parameters:
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);
};
};