public class YoutubePlayer
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
YoutubePlayer.Callback |
Modifier and Type | Field and Description |
---|---|
static int |
ERROR_UNKNOWN
Unknown error happened.
|
static int |
ERROR_VIDEO_NOT_FOUND
When the video couldn't be found.
|
static int |
STATE_BUFFERING
When the video is buffering
|
static int |
STATE_CUED
When the video is cued.
|
static int |
STATE_ENDED
When the video ends.
|
static int |
STATE_PAUSED
When the video is paused.
|
static int |
STATE_PLAYING
When the video starts playing.
|
static int |
STATE_UNKNOWN
Unknown state of the player.
|
static int |
STATE_UNSTARTED
When the video is not started yet.
|
Constructor and Description |
---|
YoutubePlayer() |
Modifier and Type | Method and Description |
---|---|
YoutubePlayer |
autoPlay(boolean autoPlay)
Sets the video to play automatically when it's loaded.
|
YoutubePlayer |
end(int end)
Sets the end point of the video.
|
void |
play(java.lang.String id)
Plays a video with the video id passed (value from v query parameter).
|
void |
play(java.lang.String id,
YoutubePlayer.Callback callback)
Plays a video with the video id passed and has a callback function that
returns the state of the the player.
|
YoutubePlayer |
start(int start)
Sets the start point of the video.
|
public static final int STATE_UNSTARTED
public static final int STATE_ENDED
public static final int STATE_PLAYING
public static final int STATE_PAUSED
public static final int STATE_BUFFERING
public static final int STATE_CUED
public static final int STATE_UNKNOWN
public static final int ERROR_VIDEO_NOT_FOUND
public static final int ERROR_UNKNOWN
public YoutubePlayer autoPlay(boolean autoPlay)
public YoutubePlayer end(int end)
end
- the end point of the video in seconds.public YoutubePlayer start(int start)
start
- the start point of the video in seconds.public void play(java.lang.String id) throws java.io.IOException
url
- the video id eg.:
https://www.youtube.com/watch?v=xBM4luqmCKs.java.io.IOException
public void play(java.lang.String id, YoutubePlayer.Callback callback) throws java.io.IOException
url
- the video id eg.:
https://www.youtube.com/watch?v=xBM4luqmCKs.callback
- the YoutubePlayer.Callbackjava.io.IOException
Callback#onStateChange(int)}