Metadata API
The following functionality is provided:
- Extract selected metadata from a file
Remark: In order to access files, a proper privilege has to be defined additionally:
- for accessing only internal storage using this API, a privilege http://tizen.org/privilege/mediastorage must be provided,
- for accessing only external storage using this API, a privilege http://tizen.org/privilege/externalstorage must be provided,
- for accessing internal and external storage using this API, privileges (http://tizen.org/privilege/mediastorage and http://tizen.org/privilege/externalstorage) must be provided.
- Storage privileges are privacy-related privileges and there is a need of asking user directly with proper pop-up. Please refer to Privacy Privilege API for more details.
For more information about how to use Metadata API, see Metadata Guide.
Since: 6.0
Table of Contents
- 1. Type Definitions
- 1.1. MetadataType
- 2. Interfaces
- 2.1. MetadataObject
- 2.2. MetadataManager
- 2.3. MetadataFileHandle
- 3. Full WebIDL
Summary of Interfaces and Methods
Interface | Method |
---|---|
MetadataObject | |
MetadataManager | |
MetadataFileHandle |
DOMString get (MetadataType type)
void release ()
|
1. Type Definitions
1.1. MetadataType
enum MetadataType { "ALBUM", "ALBUM_ARTIST", "ALTITUDE", "ARTIST", "AUDIO_BITPERSAMPLE", "AUDIO_BITRATE", "AUDIO_CHANNELS", "AUDIO_CODEC", "AUDIO_SAMPLERATE", "CLASSIFICATION", "COMMENT", "COMPOSER", "CONDUCTOR", "COPYRIGHT", "DATE", "DESCRIPTION", "DURATION", "GENRE", "HAS_AUDIO", "HAS_VIDEO", "LATITUDE", "LONGITUDE", "MODE_360", "RATING", "RECDATE", "ROTATE", "SYNCLYRICS_NUM", "TITLE", "TRACK_NUM", "UNSYNCLYRICS", "VIDEO_BITRATE", "VIDEO_CODEC", "VIDEO_FPS", "VIDEO_HEIGHT", "VIDEO_WIDTH" };
Since: 6.0
The types are:
- ALBUM - album
- ALBUM_ARTIST - album artist
- ALTITUDE - altitude
- ARTIST - artist
- AUDIO_BITPERSAMPLE - audio bits per sample
- AUDIO_BITRATE - audio bitrate
- AUDIO_CHANNELS - audio channels
- AUDIO_CODEC - audio codec
- AUDIO_SAMPLERATE - audio sample rate
- CLASSIFICATION - classification of a content
- COMMENT - comment
- COMPOSER - composer
- CONDUCTOR - conductor
- COPYRIGHT - copyright
- DATE - date
- DESCRIPTION - description
- DURATION - duration (in milliseconds)
- GENRE - genre
- HAS_AUDIO - audio stream count
- HAS_VIDEO - video stream count
- LATITUDE - latitude
- LONGITUDE - longitude
- MODE_360 - flag indicating if the video is a spherical video
- RATING - rating of a content
- RECDATE - recording date
- ROTATE - rotation (orientation) of a content
- SYNCLYRICS_NUM - synchronized lyrics (time/lyric set) number
- TITLE - title
- TRACK_NUM - track number information
- UNSYNCLYRICS - unsynchronized lyrics
- VIDEO_BITRATE - video bitrate
- VIDEO_CODEC - video codec
- VIDEO_FPS - video frame rate
- VIDEO_HEIGHT - video height
- VIDEO_WIDTH - video width
2. Interfaces
2.1. MetadataObject
[NoInterfaceObject] interface MetadataObject { readonly attribute MetadataManager metadata; };
Tizen implements MetadataObject;
Since: 6.0
The tizen.metadata object provides access to the functionality of the Metadata API.
Attributes
-
readonly
MetadataManager metadataObject representing a Metadata manager.
Since: 6.0
2.2. MetadataManager
[NoInterfaceObject] interface MetadataManager { MetadataFileHandle createFileHandle(Path path) raises(WebAPIException); };
Since: 6.0
Methods
-
createFileHandle
-
Creates representation of file for metadata operations.
MetadataFileHandle createFileHandle(Path path);
Since: 6.0
Handle is used for optimization of a process of reading multiple metadata from file. Creation of a handle does not open a file yet. For memory management optimization, handle should be released after reading all needed metadata.
Parameters:
- path: Path to the file.
Return value:
-
MetadataFileHandle:
A handle for metadata operations.
Exceptions:
- WebAPIException
with error type NotFoundError, if the path does not point to an existing file.
with error type SecurityError, if the application does not have privilege to access the storage. For more information, see Storage privileges.
with error type AbortError, if any other error occurs.
Code example:
try { var fileHandle = tizen.metadata.createFileHandle("videos/sample_video.mp4"); console.log("Created handle for file: " + fileHandle.uri); } catch (e) { console.log("Error " + JSON.stringify(e)); }
Output example:
Created handle for file: file:///opt/usr/home/owner/media/Videos/sample_video.mp4
2.3. MetadataFileHandle
[NoInterfaceObject] interface MetadataFileHandle { readonly attribute DOMString uri; DOMString get(MetadataType type) raises(WebAPIException); void release() raises(WebAPIException); };
Since: 6.0
Attributes
-
readonly
DOMString uriFile URI for a path passed to createFileHandle.
Since: 6.0
Methods
-
get
-
Extracts a metadata of a given type.
DOMString get(MetadataType type);
Since: 6.0
Parameters:
- type: A type of metadata to be extracted.
Return value:
-
DOMString:
A value of extracted metadata.
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 privilege to access the storage. For more information, see Storage privileges.
with error type AbortError, if any other error occurs.
Code example:
try { var fileHandle = tizen.metadata.createFileHandle("videos/sample_video.mp4"); console.log("Video duration is: " + fileHandle.get("DURATION") + " milliseconds"); console.log("Video title is: " + fileHandle.get("TITLE")); fileHandle.release(); } catch (e) { console.log("Error " + JSON.stringify(e)); }
Output example:
Video duration is: 70138 milliseconds Video title is: Sample Video
-
release
-
Releases all resources related to the handle and marks handle as invalid.
void release();
Since: 6.0
Exceptions:
- WebAPIException
with error type AbortError, if any error occurs.
Code example:
try { var fileHandle = tizen.metadata.createFileHandle("videos/sample_video.mp4"); /* Read metadata here */ console.log("Video duration is: " + fileHandle.get("DURATION") + " milliseconds"); /* File is no longer needed, release related resources */ fileHandle.release(); } catch (e) { console.log("Error " + JSON.stringify(e)); }
Output example:
Video duration is: 70138 milliseconds
- WebAPIException
3. Full WebIDL
module Metadata { enum MetadataType { "ALBUM", "ALBUM_ARTIST", "ALTITUDE", "ARTIST", "AUDIO_BITPERSAMPLE", "AUDIO_BITRATE", "AUDIO_CHANNELS", "AUDIO_CODEC", "AUDIO_SAMPLERATE", "CLASSIFICATION", "COMMENT", "COMPOSER", "CONDUCTOR", "COPYRIGHT", "DATE", "DESCRIPTION", "DURATION", "GENRE", "HAS_AUDIO", "HAS_VIDEO", "LATITUDE", "LONGITUDE", "MODE_360", "RATING", "RECDATE", "ROTATE", "SYNCLYRICS_NUM", "TITLE", "TRACK_NUM", "UNSYNCLYRICS", "VIDEO_BITRATE", "VIDEO_CODEC", "VIDEO_FPS", "VIDEO_HEIGHT", "VIDEO_WIDTH" }; Tizen implements MetadataObject; [NoInterfaceObject] interface MetadataObject { readonly attribute MetadataManager metadata; }; [NoInterfaceObject] interface MetadataManager { MetadataFileHandle createFileHandle(Path path) raises(WebAPIException); }; [NoInterfaceObject] interface MetadataFileHandle { readonly attribute DOMString uri; DOMString get(MetadataType type) raises(WebAPIException); void release() raises(WebAPIException); }; };