Directory

← Back

YouTubePlayer

An integrated YouTube video player with full server-side Java API

Author

Rating

YouTubePlayer component seamlessly integrates YouTube video player into a Vaadin application.

The server-side API features all standard playback controls: cue, play, pause, stop, seek, volume, mute and quality as well as state, quality, error callbacks. Supports both "chromeless" and "embedded" modes.

Use this YouTube player when you need better programmatic playback controls than with the default embedded YouTube player. See also see the interactive demo application.

Dependencies: Java 5, SWFObject Add-on v1.2.1

Sample code

// Create a YouTubePlayer
player = new YouTubePlayer();
player.setVideoId("qrO4YZeyl0I");
player.setWidth("400px");
player.setHeight("300px");
mainWindow.addComponent(player);
package org.vaadin.youtubeplayer;

import com.vaadin.Application;
import com.vaadin.ui.Button;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.Button.ClickEvent;

public class YouTubePlayerApplication extends Application {

    private static final long serialVersionUID = 1L;
    private YouTubePlayer player;
    private Button play;
    private Button pause;
    private Button stop;

    @Override
    public void init() {
        Window mainWindow = new Window("YouTubePlayer Application");

        // Create a YouTubePlayer
        player = new YouTubePlayer();
        player.setVideoId("qrO4YZeyl0I");
        player.setWidth("400px");
        player.setHeight("300px");
        mainWindow.addComponent(player);

        // Buttons
        // Buttons in horizontal order
        HorizontalLayout btns = new HorizontalLayout();
        btns.setMargin(true);
        btns.setSpacing(true);
        mainWindow.addComponent(btns);

        // Play button
        play = new Button("play", new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                player.play();
            }
        });
        btns.addComponent(play);

        // pause button
        pause = new Button("pause", new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                player.pause();
            }
        });
        btns.addComponent(pause);

        // Stop button
        stop = new Button("stop", new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                player.stop();
            }
        });
        btns.addComponent(stop);

        setMainWindow(mainWindow);
    }

}

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Fixed dynamic switching between EMBEDDED and CHROMELESS modes. Requires SWFObject 1.2.1 add-on.

Released
2011-08-02
Maturity
BETA
License
Apache License 2.0

Compatibility

Framework
Vaadin 6.3+
Browser
Internet Explorer
Internet Explorer
Firefox
Safari
Google Chrome

YouTubePlayer - Vaadin Add-on Directory

An integrated YouTube video player with full server-side Java API YouTubePlayer - Vaadin Add-on Directory
YouTubePlayer component seamlessly integrates YouTube video player into a Vaadin application. The server-side API features all standard playback controls: cue, play, pause, stop, seek, volume, mute and quality as well as state, quality, error callbacks. Supports both "chromeless" and "embedded" modes. Use this YouTube player when you need better programmatic playback controls than with the default embedded YouTube player. See also see the interactive demo application. Dependencies: Java 5, SWFObject Add-on v1.2.1
Online