Metadata API

The Metadata API provides interfaces and methods for extracting metadata information from a media file.

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 more information about how to use Metadata API, see Metadata Guide.

Since: 6.0

Table of Contents


Summary of Interfaces and Methods

Interface Method
MetadataObject
MetadataManager
MetadataFileHandle
DOMString get (MetadataType type)
void release ()

1. Type Definitions

1.1. MetadataType

Specifies the type of a 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" };

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

The MetadataObject interface defines what is instantiated in the tizen object.
  [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 metadata
    Object representing a Metadata manager.

    Since: 6.0

2.2. MetadataManager

The MetadataManager interface is the top-level interface for the Metadata API.
  [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

Object representing a file for metadata operations.
  [NoInterfaceObject] interface MetadataFileHandle {
    readonly attribute DOMString uri;
    DOMString get(MetadataType type) raises(WebAPIException);
    void release() raises(WebAPIException);
  };

Since: 6.0

Attributes

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

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