Mobile Web

MediaContent Overview

The MediaContent sample application demonstrates how content information can be retrieved from the Web Device API.

For information on creating the sample application project in the IDE, see Creating Sample Applications, and on the coding of the sample application, see Media Content task.

The following figure illustrates the screens of the MediaContent application.

Figure: MediaContent screens

MediaContent screens

The application opens with the screen where you can choose the type of storage to check. After choosing the storage, you can choose the type of files to be retrieved. To view the details of the file, click the file name.

Source Files

You can create and view the sample application project including the source files in the IDE.

File name Description
config.xml This file contains the application information for the platform to install and launch the application, including the view mode and the icon to be used in the device menu.
index.html This is a starting file from which the application starts loading. It contains the layout of the application screens.
css/style.css This file contains the CSS styling for the application UI.
js/main.js This file contains the code for the main application module used for initialization and application methods.
js/app.js This file contains the code of main logic of the application. This module uses app.model and app.ui.
js/app.model.js This file contains the code for the access to API and data management.
js/app.ui.js This file contains the code of the view logic.
js/app.ui.template.js This file contains the code of the template module.

Implementation

The config.xml file contains the specified privileges for reading from and writing to the Content API.

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" 
   <tizen:privilege name="http://tizen.org/privilege/content.read" />
   <tizen:privilege name="http://tizen.org/privilege/content.write" />
</widget>

To get all folders from the API, use the getDirectories() method from the tizen.content object.

getFolders: function getFolders(successCallback, errorCallback) 
{
   try 
   {
      tizen.content.getDirectories(successCallback, errorCallback);
   } 
   catch (exc) 
   {
      console.warn('getLocalMediaSource exc:' + exc.message);
   }
},

The following function requests for the content with a specific filter and sorted by the tizen.SortMode object.

getFolderItems: function getFolderItems(folderId, mediaType, folders, findItemsSuccess, findItemsError) 
{
   if (mediaType !== 'ALL') 
   {
      filter = new tizen.AttributeFilter('type', 'EXACTLY', mediaType);
   }
   try 
   {
      tizen.content.find(success, findItemsError, folder, filter, new tizen.SortMode('title', 'ASC'));
   } 
   catch (exc) 
   {
      console.warn('tizen.content.find exception: ' + exc.message);
   }
},

To set the storage change listener, use the addPropertyValueChangeListener() method from the tizen.systeminfo object.

addStorageChangeListener: function addChangeListener(changeListener)
{
   try 
   {
      tizen.systeminfo.addPropertyValueChangeListener('STORAGE', changeListener);
   } 
   catch (error) 
   {
      console.error('Add storage change listener error: ' + error.message);
   }
},

To set the content change listener, use setChangeListener() method from the tizen.content object.

addContentChangeListener: function addContentChangeListener(changeListener) 
{
   try 
   {
      tizen.content.setChangeListener(
      {
         oncontentadded: changeListener,
         oncontentremoved: changeListener
      });
   } 
   catch (error) 
   {
      console.error('Add content change listener error: ' + error.message);
   }
}
Go to top