Tizen - Web Application · 2015. 6. 18. · Intro. to Tizen Content API • Tizen allows you to...

19
Tizen - Web Application Tizen Content API Overview

Transcript of Tizen - Web Application · 2015. 6. 18. · Intro. to Tizen Content API • Tizen allows you to...

  • Tizen - Web Application

    Tizen Content API Overview

  • Ajou Univrsity

    Contents

    • Introduction to Tizen Content API• ContentManager interface• update• updateBatch• getDirectories• find• scanFile• setChangeListener• unsetChangeListener

  • Ajou Univrsity

    Introduction to Tizen Content API

  • Ajou Univrsity

    Intro. to Tizen Content API

    • Tizen allows you to search for contents in local devices using Content API• Type of contents include images, videos, music and etc.• Contents API also supports management tasks such as:

    • Viewing• Updating content attributes

    • Types of tizen contents are:• Content

    • General interface for contents• VideoContent, AudioContents, ImageContents

    • An extension of Content interface to contain specific attributes for each content type

    • AudioContentLyrics• Lyrics content for songs. Can be synchronized with songs

    using timestamps

  • Ajou Univrsity

    Intro. to Tizen Content API

    • Main features of Tizen Content API are:• Content Retrieval

    • Browsing and searching for content directories and contents

    • Can use filters to search for content items• Allows sorting of the search results

    • Content Management• Viewing and editing of content item details:

    • Common file information and metadata attributes• Provides scanning that allows you to find moved or copied

    items• Content Change Notifications

    • Keeps contents in an application synchronized with external content manager

  • Ajou Univrsity

    ContentManager Interface

    • ContentManager interface is used for all content-related functionalities

    • Provides operations to retrieve and manipulate content

  • Ajou Univrsity

    Tizen Content API - ContentManager

    • Update• Updates attributes of the content in content database

    synchronously• When an application has changed some attributes of a content,

    this method allows writing it back to the content database• Parameter is the content to be changed

    • Example

    https://developer.tizen.org/dev-guide/2.2.1/org.tizen.web.device.apireference/tizen/content.html#::Content::ContentManager

    The attribute “description” of this

    content is changed.

    The update function

    updates this change to the

    content database

    https://developer.tizen.org/dev-guide/2.2.1/org.tizen.web.device.apireference/tizen/content.html#::Content::ContentManager

  • Ajou Univrsity

    Tizen Content API - ContentManager

    • updateBatch

    • Updates a “batch of content attributes” in the content database synchronously

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

    • Parameters are:• Contents – an array of contents to be changed• SuccessCallback – optional, nullable function. Launched when

    attributes have been changed• ErrorCallback – optional, nullable function. Launched with following

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

  • Ajou Univrsity

    Tizen Content API - ContentManager

    • updateBatch Example

    Defining callback

    functions to display

    success or error

    message

    Increment the “rating”

    attribute by 1

  • Ajou Univrsity

    Tizen Content API - ContentManager

    • getDirectories• Returns a list of content directory objects

    • Parameters:• successCallback: Function called when content directories have

    been retrieved successfully.• This callback function can be used to process the directory objects

    that are returned

    • errorCallback [optional] [nullable]: Function called when an error has occurred

  • Ajou Univrsity

    Tizen Content API - ContentManager

    • getDirectories Example

    A function to print the

    directory information

    Upon finding directories,

    the callback function

    calls the printing

    function

  • Ajou Univrsity

    Tizen Content API - ContentManager

    • find• Finds contents using filter• The filter allows precise searching - "return all songs by artist U2,

    ordered by name"

    • Parameters• successCallback: Function called when a content have been retrieved.

    • errorCallback [optional] [nullable]: Function called when an error has occurred.

    • directoryId [optional] [nullable]: Directory ID that is use 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 content are returned.

    • count [optional] [nullable]: Maximum amount of content to return.

    • offset [optional] [nullable]: Offset of the result set.

  • Ajou Univrsity

    Tizen Content API - ContentManager

    • Example using find

    Setting the sorting mode

    and search conditions

    Print the attributes of

    each song

    Updates the offset and

    keeps searching

  • Ajou Univrsity

    Tizen Content API - ContentManager

    • scanFile

    • Scan a file to create or update a content in the content database• When an application creates or updates a content, this method

    allows scan it to insert or update the content in the content database

    • Parameters:• contentURI: The URI of the content to scan.• successCallback [optional] [nullable]: Function called when

    scanning has been completed.• errorCallback [optional] [nullable]: Function called when an error

    has occurred.

  • Ajou Univrsity

    Tizen Content API - ContentManager

    • scanFile Example

    Scans the specified path –

    file:///opt/usr/media/ for tizen.jpg

    Print success or error

    message using

    callback functions

    /opt/usr/media//opt/usr/media/tizen.jpg

  • Ajou Univrsity

    Tizen Content API - ContentManager

    • setChangeListener

    • Sets a listener to receive notifications about content changes and execute the callback function when a change is captured

    • Parameter:• changeCallback: A callback to be invoked for receiving content

    change notification

  • Ajou Univrsity

    Tizen Content API - ContentManager

    • setChangeListener Example

    Defining functions of the listener.

    This listener will be used as a

    content’s change listener

    Content’s change listener is set to the

    listener defined above

  • Ajou Univrsity

    Tizen Content API - ContentManager

    • unsetChangeListener

    • Unsets the listener to unsubscribes from receiving notificationfor any content changes

    • unsetChangeListener Example

    The content’s change listener is unset and

    the content’s change notification will not

    be handled by a listener

  • Ajou Univrsity

    References

    • Jaygarl, Hojun. "Multimedia." Professional Tizen progra

    mming development. Chichester: Wrox, 2014. 89-95. Pri

    nt.

    • https://developer.tizen.org/dev-guide/2.2.1/org.tizen.we

    b.device.apireference/tizen/content.html