GetList()

Description:

The GetList method retrieves a list of media information objects from a given service or data source of the S60 device. Each object contains information about a single media file.

This is an asynchronous method.

Syntax:

GetList(parameters:Object, callback:Object):Object

Arguments:

  • parameters:

    This is an object that specifies what media information is returned and how the returned information is sorted. For more information about the object properties and how to define them, see section Parameters for retrieving media information.

  • callback:

    The callback argument is the name of the method that is executed when GetList has results or status information to return. You must define this method separately. Follow the instructions in section Defining the callback handler for an asynchronous method to define the callback method.

Return value:

The GetList method returns an object that contains the initial return value for the asynchronous call it started (see the following table). The actual media file information is returned by the callback method in the ReturnValue property of its result object. The returned information is described in section Returned media information.

Table: Return value properties for GetList

Property

Description

Value

TransactionID

This is a number used as an identification to match transactions started with the GetList call to one or more calls it generates to callback.

 

ErrorCode

This is a number that specifies a predefined error code.

See Service API error codes.

ErrorMessage

This is a text string that describes the error.

Example code:

The following sample code illustrates how to retrieve media files from the database using GetList:

import com.nokia.lib.Service;
var media = new Service("Service.MediaManagement", "IDataSource");
var filter = {FileType:"Music", Key:"FileExtension", StartRange:".mp3"};
var inParam = {Type:"FileInfo", Filter:filter};
media.GetList(inParam,onReceive);
function onReceive(transactionID:Number, eventID:String, outParam:Object) {
  if (outParam.ErrorCode == 0) {
    var outList = outParam.ReturnValue;
    var outputEntry = null;
    do {
      outputEntry = outList.next();
      if (null != outputEntry) {
        var filename = outputEntry.FileName;
      } else {
        break;
      }
    } while (true);
  } else {
    var errorId = outParam.ErrorCode;
  }
}//callback.onLoad