Class YouTubePlayerTracker
-
- All Implemented Interfaces:
-
com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.YouTubePlayerListener
public final class YouTubePlayerTracker extends AbstractYouTubePlayerListener
Utility class responsible for tracking the state of YouTubePlayer. This is a YouTubePlayerListener, therefore to work it has to be added as listener to a YouTubePlayer.
-
-
Field Summary
Fields Modifier and Type Field Description private final PlayerConstants.PlayerStatestateprivate final FloatcurrentSecondprivate final FloatvideoDurationprivate final StringvideoId
-
Constructor Summary
Constructors Constructor Description YouTubePlayerTracker()
-
Method Summary
Modifier and Type Method Description final PlayerConstants.PlayerStategetState()final FloatgetCurrentSecond()final FloatgetVideoDuration()final StringgetVideoId()UnitonStateChange(YouTubePlayer youTubePlayer, PlayerConstants.PlayerState state)Called every time the state of the player changes. UnitonCurrentSecond(YouTubePlayer youTubePlayer, Float second)Called periodically by the player, the argument is the number of seconds that have been played. UnitonVideoDuration(YouTubePlayer youTubePlayer, Float duration)Called when the total duration of the video is loaded. UnitonVideoId(YouTubePlayer youTubePlayer, String videoId)Called when the id of the current video is loaded -
Methods inherited from class com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.AbstractYouTubePlayerListener
onApiChange, onError, onPlaybackQualityChange, onPlaybackRateChange, onReady, onVideoLoadedFraction -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getState
final PlayerConstants.PlayerState getState()
-
getCurrentSecond
final Float getCurrentSecond()
-
getVideoDuration
final Float getVideoDuration()
-
getVideoId
final String getVideoId()
-
onStateChange
Unit onStateChange(YouTubePlayer youTubePlayer, PlayerConstants.PlayerState state)
Called every time the state of the player changes. Check PlayerConstants.PlayerState to see all the possible states.
- Parameters:
state- a state from PlayerConstants.PlayerState
-
onCurrentSecond
Unit onCurrentSecond(YouTubePlayer youTubePlayer, Float second)
Called periodically by the player, the argument is the number of seconds that have been played.
- Parameters:
second- current second of the playback
-
onVideoDuration
Unit onVideoDuration(YouTubePlayer youTubePlayer, Float duration)
Called when the total duration of the video is loaded. <br></br><br></br> Note that getDuration() will return 0 until the video's metadata is loaded, which normally happens just after the video starts playing.
- Parameters:
duration- total duration of the video
-
onVideoId
Unit onVideoId(YouTubePlayer youTubePlayer, String videoId)
Called when the id of the current video is loaded
- Parameters:
videoId- the id of the video being played
-
-
-
-