Blackberry JAVA DEVELOPMENT ENVIRONMENT - - CRYPTOGRAPHIC SMART CARD DRIVER - DEVELOPMENT GUIDE Průvodce řešením problémů Strana 55

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 286
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 54
55
2: Using graphics and multimedia
Using rich media
Playing rich media content
To play rich media content, use the following classes:
To retrieve .pme content from BlackBerry® devices or networks, use methods from the MediaManager class.
To play .pme content that exists on BlackBerry devices, use methods from the MediaPlayer class.
Download rich media content
1. Create a MediaManager object.
2. Invoke MediaManager.createMedia().
The first time that you invoke MediaManager.createMedia(), the URL must be absolute, unless you first
invoke
MediaManager.setProperty(“URI_BASE”, <base_url>) to set a base URL. When you invoke
createMedia() subsequently, the URL that the method used previously is the base.
MediaManager manager = new MediaManager();
try {
Object media = manager.createMedia("http://webserver/sample.pme");
} catch (IOException ioe) {
System.out.println("Error: requested content was not downloaded.");
} catch (MediaException me) {
System.out.println("Error: “ + me.getCode()); }
Play rich media content
Send a media player event to
a registered player listener.
>Invoke playerUpdate(Player player, String event, Object eventData).
public void playerUpdate(Player player,String event, Object eventData)
{// Release resources
player.close();
if ( event == PlayerListener.END_OF_MEDIA )
// Add code for actions if the end of media is reached.
}
Task Steps
Set the .pme object for
playback.
>Invoke MediaPlayer.setMedia().
MediaPlayer player = new MediaPlayer();
try {
player.setMedia(media);
} catch (MediaException me) {
System.out.println("Error: requested content type is not supported.”);
}
Task Steps
Zobrazit stránku 54
1 2 ... 50 51 52 53 54 55 56 57 58 59 60 ... 285 286

Komentáře k této Příručce

Žádné komentáře