com.vodafone.v10.system.media
Interface ResourceOperator


public interface ResourceOperator

ResourceOperator is an interface defining methods for getting information about melody, image and other resources registered in the handset. It may also be used for setting resources in a media player.

To obtain a ResourceOperator object, use the ResourceOperatorManager static method getResourceOperator(). ResourceOperator objects must be obtained separately for melody resources and for image resources.

When using the methods provided in the ResourceOperator class, information such as the number of resources of each kind, their title strings, etc., can be obtained. This information may be obtain using the following sequence:

  1. The getResourceCount() method is called to get the number of resources registered in the handset.

  2. An identifier is obtained for each resource by calling getResourceID(). Index values are assigned starting from 0, up to a value one less than the value obtained by getResourceCount().

  3. The title string of each resource is obtained using getResourceName().

It is also possible to get all the resource title names in a String object array by using getResourceNames(). The title names are used for displaying resources to the user.

After resource titles are displayed in a list, from which the user chooses a resource to be played, the selected resource is set in a MediaPlayer object. There are three different kinds of methods for this purpose as follows, each with different parameters.

A Java application programmer does not need to be concerned about the internal structure of the media resources handled by ResourceOperator, other than to make allowance for the possibility that not all media resources will be playable by MediaPlayer. When playback is not possible, an exception is thrown at the time the media is set.


Method Summary
 int getIndexOfResource(int id)
          Gets a resource index corresponding to a resource ID.
 int getResourceCount()
          Gets the number of resources registered in the handset.
 int getResourceID(int index)
          Gets the identifier of a resource registered in the handset.
 java.lang.String getResourceName(int id)
          Gets the name of a resource registered in the handset.
 java.lang.String[] getResourceNames()
          Gets the names of resources registered in the handset.
 int getResourceType()
          Gets the resource type.
 void setResource(MediaPlayer player, int index)
          Sets a resource in a MediaPlayer by designating its resource index.
 void setResourceByID(MediaPlayer player, int id)
          Sets a resource in a MediaPlayer by designating its resource ID.
 void setResourceByTitle(MediaPlayer player, java.lang.String name)
          Sets a resource in a MediaPlayer by designating its resource name.
 

Method Detail

getResourceType

public int getResourceType()
Gets the resource type.
Returns:
int - Resource type
  • MediaResourceManager.MELODY_RESOURCE
  • MediaResourceManager.IMAGE_RESOURCE

getResourceCount

public int getResourceCount()
Gets the number of resources registered in the handset.
Returns:
int - Resource count

getResourceID

public int getResourceID(int index)
Gets the identifier of a resource registered in the handset.
Parameters:
index - Resource index
Returns:
int - Resource ID corresponding to the resource index
Throws:
IllegalArgumentException - if no resource ID could be obtained for the resource index.
RuntimeException - if the resource could not be obtained from the native system.

getResourceName

public java.lang.String getResourceName(int id)
Gets the name of a resource registered in the handset.
Parameters:
id - Resource ID
Returns:
String - Resource name correspoinding to the resource ID
Throws:
IllegalArgumentException - if an illegal resource ID was designated.

getResourceNames

public java.lang.String[] getResourceNames()
Gets the names of resources registered in the handset.
Returns:
String[] - An array holding the names of resources registered in the handset. If there are no resources, null is returned.
Throws:
RuntimeException - if the resources could not be obtained from the native system.

setResourceByID

public void setResourceByID(MediaPlayer player,
                            int id)
Sets a resource in a MediaPlayer by designating its resource ID.
Parameters:
player - Media player
id - Resource ID
Throws:
IllegalArgumentException - if an illegal resource ID was designated.
IllegalStateException - if a playing or paused MediaPlayer was designated.
RuntimeException - if the resource could not be set in the native system.

setResourceByTitle

public void setResourceByTitle(MediaPlayer player,
                               java.lang.String name)
Sets a resource in a MediaPlayer by designating its resource name. If the name exists more than once, the first discovered resource is used.
Parameters:
player - Media player
name - Resource name
Throws:
IllegalStateException - if a playing or paused MediaPlayer was designated.
IllegalStateException - if the designated resource was not found.
RuntimeException - if the resource could not be set in the native system.
IllegalArgumentException - if player or name is null.

setResource

public void setResource(MediaPlayer player,
                        int index)
Sets a resource in a MediaPlayer by designating its resource index.
Parameters:
player - Media player
index - Resource index
Throws:
IllegalArgumentException - if the designated resource was not found.
IllegalStateException - if a playing or paused MediaPlayer was designated.
RuntimeException - if the resource could not be set in the native system.

getIndexOfResource

public int getIndexOfResource(int id)
Gets a resource index corresponding to a resource ID.
Parameters:
id - Resource ID
Returns:
int - Resource index corresponding to the designated resource ID
Throws:
IllegalArgumentException - if an illegal resource ID was designated.


Copyright 2002,2003 Aplix Corporation. All rights reserved. Aplix Confidential and Restricted.