質問

ビデオ画面が必要なビデオプレイの下で、私は以下のような2行のテキストを表示したいです。

モデル表示

次のコードを使用しています。

public final class PlayVideoScreen extends MainScreen {
    private Player player;
    private VideoControl videoControl;

    public PlayVideoScreen() {

        // ms.setTitle(new LabelField("Let's play some video..."));
        LabelField lf = new LabelField("Video Play");

        try {
            // Create a new Player pointing to the video file.
            // This can use any valid URL.
            player = javax.microedition.media.Manager
                    .createPlayer("file:///SDCard/BlackBerry/videos/sample.avi");

            player.realize();

            // Create a new VideoControl.
            videoControl = (VideoControl) player.getControl("VideoControl");
            // Initialize the video mode using a Field.
            Field videoField = (Field) videoControl.initDisplayMode(
                    VideoControl.USE_GUI_PRIMITIVE,
                    "net.rim.device.api.ui.Field");

            add(videoField);

            VolumeControl volume = (VolumeControl) player
                    .getControl("VolumeControl");
            volume.setLevel(30);


            player.start();

            // Set the video control to be visible.
            // videoControl.setVisible(true);
        } catch (MediaException me) {
            Dialog.alert(me.toString());
        } catch (IOException ioe) {
            Dialog.alert(ioe.toString());
        }

        add(lf);

         LabelField lf2 = new LabelField("How r you?");

         add(lf2);
    }

    public boolean onClose() {
        // Clean up the player resources.
        player.close();
        videoControl.setVisible(false);
        close();
        return true;
    }
}
.

今すぐビデオの高さがあるかもしれません、ビューはスクロールしているとスクロール後にのみ表示されます。スクリーンサイズ320x240pxのデバイスを使用しています。320 x 150pxのビデオでもテストしています。しかし、テキストはスクロールせずに見えないが、ビデオの上下の空き容量がたくさんありますが。コードの問題は何ですか?それを解決する方法?

役に立ちましたか?

解決

あなたの問題を解決する方法はいくつかあります。あなたのケースの最も簡単なことは、 mainScreen#setstatus この画面のステータスセクションの内容を設定します。

LabelFieldsを直接追加する代わりに、次のように追加します。

VerticalFieldManager vfm = new VerticalFieldManager();
vfm.add(lf);
vfm.add(lf2);
setStatus(vfm);
.


編集:代替ソリューションはレイアウトして子フィールドを自分で位置づけることです。そのため、PlayVideスクリーンのsublayout()をオーバーライドするか、別のマネージャ(VerticalFieldManager)を導入し、すべてのフィールド(ビデオとラベル)を追加し、そのsublayout()メソッドをオーバーライドできます。

下記は上記の修正を含むコードです

public PlayVideoScreen() {
    super(NO_VERTICAL_SCROLL);

    // ms.setTitle(new LabelField("Let's play some video..."));
    final LabelField lf = new LabelField("Video Play");

    try {
        // Create a new Player pointing to the video file.
        // This can use any valid URL.
        player = javax.microedition.media.Manager
                .createPlayer("file:///SDCard/BlackBerry/videos/sample.avi");

        player.realize();

        // Create a new VideoControl.
        videoControl = (VideoControl) player.getControl("VideoControl");
        // Initialize the video mode using a Field.
        final Field videoField = (Field) videoControl.initDisplayMode(
            VideoControl.USE_GUI_PRIMITIVE,
            "net.rim.device.api.ui.Field");

            VolumeControl volume = (VolumeControl) player
                    .getControl("VolumeControl");
        volume.setLevel(30);

        player.start();

        // Set the video control to be visible.
        // videoControl.setVisible(true);

        final LabelField lf2 = new LabelField("How r you?");

        VerticalFieldManager vfm = new VerticalFieldManager(NO_VERTICAL_SCROLL) {
            protected void sublayout(int maxWidth, int maxHeight) {
                int heightLeft = maxHeight;

                // layout the children fields
                layoutChild(lf, maxWidth, heightLeft);
                heightLeft -= lf.getHeight();

                layoutChild(lf2, maxWidth, heightLeft);
                heightLeft -= lf2.getHeight();

                layoutChild(videoField, maxWidth, heightLeft);

                // position the children fields
                int yPos = 0;
                setPositionChild(videoField, 0, yPos);
                yPos += videoField.getHeight();

                setPositionChild(lf, 0, yPos);
                yPos += lf.getHeight();

                setPositionChild(lf2, 0, yPos);

                setExtent(maxWidth, maxHeight);
            };
        };
        vfm.add(videoField);
        vfm.add(lf);
        vfm.add(lf2);

        add(vfm);

    } catch (MediaException me) {
        Dialog.alert(me.toString());
    } catch (IOException ioe) {
        Dialog.alert(ioe.toString());
    }
}
.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top