Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Revision as of 05:26, 4 October 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Loading images in Symbian Web Runtime

From Wiki
Jump to: navigation, search
Article Metadata
Code ExampleTested with
Devices(s): Nokia 5800 XpressMusic
Platform(s): S60 5th Edition
S60 5th Edition
Keywords: device.getServiceObject(), Service.MediaManagement.GetList()
Created: ivruban (10 Dec 2008)
Last edited: hamishwillee (04 Oct 2012)



This code snippet shows how to asynchronously get a list of images using the Media Management Platform Service for Symbian Web Runtime. This service was introduced in S60 5th Edition.

To obtain access to the service object for the Media Management Service API, the device.getServiceObject("Service.MediaManagement", "IDataSource") method is used.

Source: Relevant HTML components

<div id="bodyContent" class="bodyContent">
<select size="5" id="imageList" onclick="show();"></select><br />
<img id="imageShow" alt="" src="" />

Source: imageviewer.js

//Object available through a Service API. Declare service object,
//that is used to access the multimedia services.
var multimediaServiceObject = null;
window.onload = init;
// Initializes the widget
function init() {
try {
//Getting service object for multimedia.
multimediaServiceObject =
device.getServiceObject("Service.MediaManagement", "IDataSource");
//Setting file criteria.
var criteria = new Object();
criteria.Type = "FileInfo";
criteria.Filter = new Object();
criteria.Filter.FileType = "Image";
criteria.Sort = new Object();
criteria.Sort.Key = "FileSize";
//Asynchronous function for fetching files.
result =
multimediaServiceObject.IDataSource.GetList(criteria, callback);
} catch( exception ) {
alert("initialize error: " + exception);
* A callback function used to handle results of fetching multimedia files.
* @param transId A number representing the transaction that called the
* callback
* @param eventCode A number representing the callback return status
* @param result An object for holding the callback return value

function callback(transId, eventCode, result) {
if(result.ErrorCode != 0) {
alert("Error in creating file list:" + result.ErrorCode);
* Creates a list item for every multimedia file in "iterator".
* @param iterator The list of files

function createFileList(iterator) {
var imageList = document.getElementById("imageList");
//Reset to set pointer to the first element.
var item;
//Cleaning the file list.
while (imageList.length != 0) {
while ((item = iterator.getNext()) != undefined) {
var node = document.createElement("option");
//Value of option consists of the full path.
node.value = item.FileNameAndPath;
node.appendChild(document.createTextNode(item.FileName +
* Shows the selected image.

function show() {
var imageList = document.getElementById("imageList");
for(var i = 0; i < imageList.options.length; i++) {
if (imageList.options[i].selected) {
document.getElementById("imageShow").src =


  • When the snippet is started, all available image names are loaded into the list box.
  • When clicking on the image name, the image content is loaded and displayed.

Supplementary material

You can view the source file and executable application in the attached ZIP archive. The archive is available for download at Media:Loading images in

This page was last modified on 4 October 2012, at 05:26.
53 page views in the last 30 days.