在BlackBerry中播放m4v和m4a

时间:2012-10-28 17:13:52

标签: blackberry java-me

我使用以下代码在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());
        }

    }
}

0 个答案:

没有答案