我使用以下代码在 BlackBerry 上播放 .m4a 和 .m4a 歌曲。但是当尝试播放 .m4v 歌曲时,它会给出一条错误消息,例如“格式不支持”。
public VideoPlaybackDemoScreen() {
Class cl = null;
try {
cl = Class.forName("mypackage.VideoPlaybackDemoScreen");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
if (cl != null) {
try {
InputStream is = getClass().getResourceAsStream(
"/mzm.yzzwpvvt..640x348.h264lc.u.p.m4v");
final Player player = javax.microedition.media.Manager
.createPlayer(is, "video/m4v");
player.realize();
VideoControl videoControl = (VideoControl) player
.getControl("VideoControl");
Field videoField = (Field) videoControl.initDisplayMode(
VideoControl.USE_GUI_PRIMITIVE,
"net.rim.device.api.ui.Field");
videoControl.setDisplaySize(480, 256);
videoControl.setVisible(true);
add(new LabelField("Top", 0));
add(videoField);
add(new LabelField("Bottom", 0));
final int i = 30;
final VolumeControl volume = (VolumeControl) player
.getControl("VolumeControl");
ButtonField volumeIncrease = new ButtonField("Volume Increase") {
protected boolean navigationClick(int status, int time) {
VolumeControl volC = (VolumeControl) player
.getControl("VolumeControl");
int volume = volC.getLevel() + 10;
volC.setLevel(volume);
Dialog.alert(String.valueOf(volume));
return true;
}
};
ButtonField volumeDecrease = new ButtonField("Volume Decrese") {
protected boolean navigationClick(int status, int time) {
VolumeControl volC = (VolumeControl) player
.getControl("VolumeControl");
int volume = volC.getLevel() - 10;
volC.setLevel(volume);
return true;
}
};
add(volumeIncrease);
add(volumeDecrease);
player.start();
} catch (IOException e) {
Dialog.alert(e.getMessage());
} catch (MediaException e) {
Dialog.alert(e.getMessage());
}
}
}