在j2me上指定视频旋转方向

时间:2012-03-17 10:10:19

标签: video java-me rotation lwuit

我有播放视频的j2me应用程序。在客户端设备上,它会旋转到反方向。

我想知道的是,在LWUIT中是否有任何方法可用于视频旋转(以指定旋转方向),因此根据我们的应用,我们可以将视频旋转到所需的方向?

2 个答案:

答案 0 :(得分:1)

据我所知你不能这样做,但你可以看一下可能有某些东西的高级MMAPI规范(JSR 234)。

答案 1 :(得分:1)

只要我理解,您就可以在SonyEricsson JP-7或更高版本上旋转视频 http://i48.tinypic.com/vn08ye.png

http://i49.tinypic.com/w2fz0i.png

以下是我使用的代码段:

    //boolean rotate90 indicates whether we want to rotate it

    private void setDisplay(boolean init) {
        if(videoControl == null) return;

        boolean rotate = false;
        trans = Sprite.TRANS_NONE;

        if (rotate90) {
            rotate = true;
            trans = Sprite.TRANS_ROT90;
        }

        if (init) {
            try {
                // video rotate
                videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO | (trans << 4), this);
            } catch (Throwable e) { // not supported by device
                // direct video
                trans = Sprite.TRANS_NONE;
                videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);
            }
        }
        videoControl.setVisible(false);

        int dw, dh;

        //set up target width (dw), and target height (dh) as desired...
        //...
        //...


        try {
            videoControl.setDisplaySize(dw, dh);
        }
        catch(Throwable e) {
            //...
        }
        videoControl.setVisible(true);
    }


    // rotate during playback
    private void rotateVideo() {
        // if we dont't have it, reinit video with new rotation and set current media time
        if (!Main.classExists("com.sonyericsson.media.control.DisplayModeControl")) replayVideo();
        else {
            setDisplay(false); // resize our picture, no init
            // rotate the video.
            com.sonyericsson.media.control.DisplayModeControl dmc = (com.sonyericsson.media.control.DisplayModeControl)player.getControl("com.sonyericsson.media.control.DisplayModeControl");
            dmc.setDisplayMode(rotate90 ? (Sprite.TRANS_ROT90 << 4) : (Sprite.TRANS_NONE << 4));
            dmc = null;
        }
    }

    private void replayVideo() {
        long prevtime = player.getMediaTime();
        play(); //reopen file, Manager.createPlayer, setDIsplay(true), etc.
        try {
            playerPause();
            player.setMediaTime(prevtime);
            playerStart();
        }
        catch(MediaException me) { }
    }