Since video decoding consumes both processing time and battery power, it can be practical to stop the decoding when the video being played is not visible in the device UI. For example, if the user is reading a message, viewing images, navigating the UI menus, or performing some other foreground task that fully covers the video being played in the background, decoding can be temporarily stopped. The video continues to play in the background, but the video stream is not processed in any way, saving processing time and battery power. When the video becomes visible again in the device UI, the MIDlet can resume decoding it, so that the user can see the video content.
To allow MIDlets to stop and resume video decoding during video
playback, the Series 40 platform supports the VideoDecodeControl
extension interface for
the Mobile Media API (MMAPI). The VideoDecodeControl
interface is intended for video player MIDlets that do not stop
video decoding automatically when the MIDlet is moved to the background.
Compared to the automatic stopping and starting of video decoding,
the VideoDecodeControl
interface allows for finer
control over when video decoding is used.
Depending on the video content and the Player
implementation,
stopping and resuming video decoding can cause short-term image distortion
visible to the user. To avoid this, program the MIDlet to stop video
decoding only when the benefits of saved processing time and battery
power outweigh the drawbacks of a poor user experience caused by image
distortion. For example, stopping video decoding can be practical
when the user causes an application or a UI element to fully cover
the video area, but not when the video area becomes only partially
covered, leaving a portion of the video visible.
For more information about creating a video Player
, see section Playing video.
VideoDecodeControl
is supported
on Series 40 devices with Java Runtime 2.0.0.
To stop video decoding during playback, create
a VideoDecodeControl
instance for the corresponding Player
, and call setDecodeStatus(VideoDecodeControl.DECODE_STATUS_OFF)
on it:
// create a VideoDecodeControl for the Player instance VideoDecodeControl vdc = (VideoDecodeControl)player.getControl("VideoDecodeControl"); // stop video decoding while the video is still playing if (vdc != null) vdc.setDecodeStatus(VideoDecodeControl.DECODE_STATUS_OFF);
For a fuller code example, see the VideoDecodeControl
specification.
To resume video decoding during playback,
call setDecodeStatus(VideoDecodeControl.DECODE_STATUS_FULL)
on the VideoDecodeControl
instance:
vdc.setDecodeStatus(VideoDecodeControl.DECODE_STATUS_FULL);
To check whether video decoding is
enabled or disabled for the Player
, call getDecodeStatus()
on the VideoDecodeControl
instance:
int status = vdc.getDecodeStatus();
If video decoding is enabled, the method returns VideoDecodeControl.DECODE_STATUS_FULL
. If video decoding is disabled, the method returns VideoDecodeControl.DECODE_STATUS_OFF
.