Example usage for com.google.gwt.dom.client MediaElement PRELOAD_AUTO

List of usage examples for com.google.gwt.dom.client MediaElement PRELOAD_AUTO

Introduction

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

Prototype

String PRELOAD_AUTO

To view the source code for com.google.gwt.dom.client MediaElement PRELOAD_AUTO.

Click Source Link

Document

Constant used by #getPreload() and #setPreload(String) .

Usage

From source file:com.ait.lienzo.client.core.shape.Movie.java

License:Open Source License

private final MovieAnimation doInitialize() {
    if (null != m_video) {
        setErrorHandler(this, m_video.getVideoElement());

        String url = getURL();//from  ww w.  j a va  2s .co  m

        if ((null == url) || ((url = url.trim()).isEmpty()) || (url.startsWith("#"))) {
            throw new NullPointerException("null or empty or invalid url");
        }
        url = UriUtils.fromString(url).asString();

        if ((null == url) || ((url = url.trim()).isEmpty()) || (url.startsWith("#"))) {
            throw new NullPointerException("null or empty or invalid url");
        }
        m_video.setSrc(url);

        m_video.setLoop(isLoop());

        m_video.setVisible(false);

        m_video.setPlaybackRate(getPlaybackRate());

        m_video.setPreload(MediaElement.PRELOAD_AUTO);

        if (getAttributes().isDefined(Attribute.VOLUME)) {
            m_video.setVolume(getVolume());
        }
        setSizes();

        return new MovieAnimation(this, m_video);
    } else {
        return null;
    }
}

From source file:com.emitrom.lienzo.client.core.shape.Movie.java

License:Open Source License

/**
 * Constructor. Creates an instance of a movie.
 * /*from w w  w.  ja v  a  2  s.  co m*/
 * @param url
 */
public Movie(String url) {
    super(ShapeType.MOVIE);

    getAttributes().setURL(url);

    if (null != m_video) {
        m_video.setSrc(getURL());

        m_video.setLoop(false);

        m_video.setVisible(false);

        m_video.setPreload(MediaElement.PRELOAD_AUTO);
    }
}

From source file:nl.mpi.tg.eg.experiment.client.view.TimedStimulusView.java

License:Open Source License

public Element addTimedVideo(final TimedEventMonitor timedEventMonitor, final SafeUri oggPath,
        final SafeUri ogvPath, final SafeUri mp4Path, int percentOfPage, int maxHeight, int maxWidth,
        final String styleName, final boolean autoPlay, final boolean loop, final boolean showControls,
        final CancelableStimulusListener loadedStimulusListener,
        final CancelableStimulusListener failedStimulusListener,
        final CancelableStimulusListener playbackStartedStimulusListener,
        final CancelableStimulusListener playedStimulusListener, final String mediaId) {
    cancelableListnerList.add(loadedStimulusListener);
    cancelableListnerList.add(failedStimulusListener);
    cancelableListnerList.add(playbackStartedStimulusListener);
    cancelableListnerList.add(playedStimulusListener);
    final Element videoElement;
    if (timedEventMonitor != null) {
        timedEventMonitor.registerEvent("addTimedVideo");
    }//from  w w w . j  a  va  2  s .  c om
    final Video video = Video.createIfSupported();
    if (video == null) {
        failedStimulusListener.postLoadTimerFired();
        videoElement = null;
    } else {
        video.setAutoplay(autoPlay);
        videoList.put(mediaId, video);
        //            video.setPoster(poster);
        video.setControls(showControls);
        video.setPreload(MediaElement.PRELOAD_AUTO);
        if (styleName != null && !styleName.isEmpty()) {
            video.addStyleName(styleName);
        } else {
            addSizeAttributes(video.getElement(), percentOfPage, maxHeight, maxWidth);
        }
        getActivePanel().add(video);
        video.addCanPlayThroughHandler(new CanPlayThroughHandler() {
            boolean hasTriggeredOnLoaded = false;

            @Override
            public void onCanPlayThrough(CanPlayThroughEvent event) {
                if (!hasTriggeredOnLoaded) {
                    if (timedEventMonitor != null) {
                        timedEventMonitor.registerEvent("videoCanPlayThrough");
                    }
                    hasTriggeredOnLoaded = true;
                    loadedStimulusListener.postLoadTimerFired();
                    if (autoPlay) {
                        video.play();
                    }
                    if (video.getError() != null) {
                        // todo: check that this method is functioning correctly and if not then use the method in audioPlayer.@nl.mpi.tg.eg.experiment.client.service.AudioPlayer::onAudioFailed()();
                        failedStimulusListener.postLoadTimerFired();
                    }
                }
            }
        });
        new VideoPlayer().addNativeCallbacks(timedEventMonitor, video.getVideoElement(),
                playbackStartedStimulusListener);
        //            todo: move the video handling code from here into the VideoPlayer class, in such a way is it can be used like the AudioPlayer class of the same package
        video.addEndedHandler(new EndedHandler() {
            private boolean triggered = false;

            @Override
            public void onEnded(EndedEvent event) {
                if (timedEventMonitor != null) {
                    timedEventMonitor.registerEvent("videoEnded");
                    timedEventMonitor.registerMediaLength(mediaId, (long) (video.getCurrentTime() * 1000));
                }
                // prevent multiple triggering
                if (!triggered) {
                    triggered = true;
                    //                        Timer timer = new Timer() {
                    //                            public void run() {
                    playedStimulusListener.postLoadTimerFired();
                    //                            }
                    //                        };
                    //                        timerList.add(timer);
                    //                        timer.schedule(postLoadMs);
                }
            }
        });
        if (oggPath != null) {
            video.addSource(oggPath.asString(), "video/ogg");
        }
        if (ogvPath != null) {
            video.addSource(ogvPath.asString(), "video/ogg");
        }
        if (mp4Path != null) {
            video.addSource(mp4Path.asString(), "video/mp4");
        }

        if (!autoPlay) {
            video.pause();
            video.setCurrentTime(0);
        }
        video.setLoop(loop);
        video.load();
        if (video.getError() != null) {
            // todo: check that this method is functioning correctly and if not then use the method in audioPlayer.@nl.mpi.tg.eg.experiment.client.service.AudioPlayer::onAudioFailed()();
            failedStimulusListener.postLoadTimerFired();
        }
        videoElement = video.getElement();
    }
    return videoElement;
}

From source file:nl.mpi.tg.eg.experiment.client.view.VideoPanel.java

License:Open Source License

public VideoPanel(String width, String poster, String src) {
    video = Video.createIfSupported();/*  w ww . java  2s  .  com*/
    if (video != null) {
        video.setPoster(poster);
        video.setControls(true);
        video.setPreload(MediaElement.PRELOAD_AUTO);
        this.add(video);
    } else {
        this.add(new Label("Video is not supported"));
    }
    addSource(src + ".mp4", "video/mp4");
    addSource(src + ".ogg", "video/ogg");
    addSource(src + ".webm", "video/webm");
}