Example usage for com.google.gwt.dom.client VideoElement TYPE_OGG

List of usage examples for com.google.gwt.dom.client VideoElement TYPE_OGG

Introduction

In this page you can find the example usage for com.google.gwt.dom.client VideoElement TYPE_OGG.

Prototype

String TYPE_OGG

To view the source code for com.google.gwt.dom.client VideoElement TYPE_OGG.

Click Source Link

Document

The audio type of Ogg encoded video.

Usage

From source file:com.google.gwt.sample.mobilewebapp.client.desktop.MobileWebAppShellDesktop.java

License:Apache License

/**
 * Show a tutorial video./*  w w  w .j a va 2 s  .c  om*/
 */
private void showTutorial() {
    // Reuse the tutorial dialog if it is already created.
    if (tutoralPopup != null) {
        // Reset the video.
        // TODO(jlabanca): Is cache-control=private making the video non-seekable?
        if (tutorialVideo != null) {
            tutorialVideo.setSrc(tutorialVideo.getCurrentSrc());
        }

        tutoralPopup.center();
        return;
    }

    /*
     * Forward the use to YouTube if video is not supported or if none of the
     * source formats are supported.
     */
    tutorialVideo = Video.createIfSupported();
    if (tutorialVideo == null) {
        Label label = new Label("Click the link below to view the tutoral:");
        Anchor anchor = new Anchor(EXTERNAL_TUTORIAL_URL, EXTERNAL_TUTORIAL_URL);
        anchor.setTarget("_blank");
        FlowPanel panel = new FlowPanel();
        panel.add(label);
        panel.add(anchor);

        tutoralPopup = new PopupPanel(true, false);
        tutoralPopup.setWidget(panel);
        tutoralPopup.setGlassEnabled(true);

        // Hide the popup when the user clicks the link.
        anchor.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                tutoralPopup.hide();
            }
        });

        tutoralPopup.center();
        return;
    }

    // Add the video sources.
    tutorialVideo.addSource("video/tutorial.ogv", VideoElement.TYPE_OGG);
    tutorialVideo.addSource("video/tutorial.mp4", VideoElement.TYPE_MP4);

    // Setup the video player.
    tutorialVideo.setControls(true);
    tutorialVideo.setAutoplay(true);

    // Put the video in a dialog.
    final DialogBox popup = new DialogBox(false, false);
    popup.setText("Tutorial");
    VerticalPanel vPanel = new VerticalPanel();
    vPanel.add(tutorialVideo);
    vPanel.add(new Button("Close", new ClickHandler() {
        public void onClick(ClickEvent event) {
            tutorialVideo.pause();
            popup.hide();
        }
    }));
    popup.setWidget(vPanel);
    tutoralPopup = popup;
    popup.center();
}

From source file:net.cbtltd.client.field.MediaControl.java

/**
 * Sets the ID of a video object./*  w  w  w .  j a  v  a2s.  com*/
 *
 * @param value the new ID of the video object.
 */
public void setVideoValue(String value) {
    Log.debug("setVideoValue " + value);
    try {
        this.value = value;
        if (media == null || value == null || value.isEmpty()) {
            return;
        }

        else if (MediaElement.CAN_PLAY_PROBABLY.equals(media.canPlayType(VideoElement.TYPE_MP4))) {
            media.setSrc(HOSTS.rootUrl() + HasUrls.VIDEO_DIRECTORY + value + Text.VIDEO_MP4);
        } else if (MediaElement.CAN_PLAY_PROBABLY.equals(media.canPlayType(VideoElement.TYPE_OGG))) {
            media.setSrc(HOSTS.rootUrl() + HasUrls.VIDEO_DIRECTORY + value + Text.VIDEO_OGG);
        } else if (MediaElement.CAN_PLAY_PROBABLY.equals(media.canPlayType(VideoElement.TYPE_WEBM))) {
            media.setSrc(HOSTS.rootUrl() + HasUrls.VIDEO_DIRECTORY + value + Text.VIDEO_WEBM);
        }

        else if (MediaElement.CAN_PLAY_MAYBE.equals(media.canPlayType(VideoElement.TYPE_MP4))) {
            media.setSrc(HOSTS.rootUrl() + HasUrls.VIDEO_DIRECTORY + value + Text.VIDEO_MP4);
        } else if (MediaElement.CAN_PLAY_MAYBE.equals(media.canPlayType(VideoElement.TYPE_OGG))) {
            media.setSrc(HOSTS.rootUrl() + HasUrls.VIDEO_DIRECTORY + value + Text.VIDEO_OGG);
        } else if (MediaElement.CAN_PLAY_MAYBE.equals(media.canPlayType(VideoElement.TYPE_WEBM))) {
            media.setSrc(HOSTS.rootUrl() + HasUrls.VIDEO_DIRECTORY + value + Text.VIDEO_WEBM);
        } else {
            return;
        }
        media.load();
        //media.setPreload(MediaElement.PRELOAD_AUTO);
        Log.debug("loaded " + value);
    } catch (Exception x) {
        Log.error("setVideoValue " + HOSTS.rootUrl() + HasUrls.AUDIO_DIRECTORY + value);
    }
}