|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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:
The getResourceCount()
method is called to get the number of resources registered in the handset.
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()
.
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 |
public int getResourceType()
public int getResourceCount()
public int getResourceID(int index)
index
- Resource indexIllegalArgumentException
- if no resource ID could be obtained for the
resource index.RuntimeException
- if the resource could not be obtained from the native system.public java.lang.String getResourceName(int id)
id
- Resource IDIllegalArgumentException
- if an illegal resource ID was designated.public java.lang.String[] getResourceNames()
RuntimeException
- if the resources could not be obtained from the native system.public void setResourceByID(MediaPlayer player, int id)
player
- Media playerid
- Resource IDIllegalArgumentException
- 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.public void setResourceByTitle(MediaPlayer player, java.lang.String name)
player
- Media playername
- Resource nameIllegalStateException
- 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.public void setResource(MediaPlayer player, int index)
player
- Media playerindex
- Resource indexIllegalArgumentException
- 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.public int getIndexOfResource(int id)
id
- Resource IDIllegalArgumentException
- if an illegal resource ID was designated.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |