Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Playing media in a BlackBerry Application

by Retired ‎02-12-2010 02:58 PM - edited ‎09-17-2010 04:33 PM (3,746 Views)

Exercise

 

Create a BlackBerry Application that uses the Player interface and the javax.microedition.media (JSR 135) package to play media.

 

Objectives

  • Discover how to use the Player interface to playback video.
  • Discover how to use the PlayerListener interface to listen for changes to the state of the media application.
  • Discover how to record changes to the volume key to adjust the volume of the media application.

Setup

  1. Download the file
  2. In the IDE, open the multimediademo.jdw workspace
  3. Open the MultimediaDemo.java source file.

Tasks

  1. In the VideoScreen constructor, setup and initialize Player.
  2. Complete the onClose method for the VideoScreen so that Player resources are cleaned up before the application exits.
  3. Implement the setVolume method so that it sets the right volume level for the Player.
  4. Complete the run method for the fullscreen MenuItem so that Player can be switched to the full screen mode.
  5. Complete the run method for the pauseItem MenuItem so that Player is started and stopped depending on the current state.
  6. Fill in the if blocks under the keyControl method so that volume is increased or decreased based on the volume key pressed.
  7. Implement playerUpdate method so that Player events are shown in the eventField.

Check Your Work

 

Download the completed code

 

Review

 

In this exercise, you discovered the following things:

  • How to use the Player interface to playback a video.
  • How to use the PlayerListener to detect changes in the Player state.
  • How to record changes to the volume key to set the Player volume level.
Contributors
Users Online
Currently online: 37 members 1,035 guests
Please welcome our newest community members: