-
- 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 PlayerConstants.PlayerStatestateprivate FloatcurrentSecondprivate FloatvideoDurationprivate StringvideoId
-
Constructor Summary
Constructors Constructor Description YouTubePlayerTracker()
-
Method Summary
Modifier and Type Method Description final PlayerConstants.PlayerStategetState()final UnitsetState(PlayerConstants.PlayerState state)final FloatgetCurrentSecond()final UnitsetCurrentSecond(Float currentSecond)final FloatgetVideoDuration()final UnitsetVideoDuration(Float videoDuration)final StringgetVideoId()final UnitsetVideoId(String videoId)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.utils.YouTubePlayerTracker
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()
-
setState
final Unit setState(PlayerConstants.PlayerState state)
-
getCurrentSecond
final Float getCurrentSecond()
-
setCurrentSecond
final Unit setCurrentSecond(Float currentSecond)
-
getVideoDuration
final Float getVideoDuration()
-
setVideoDuration
final Unit setVideoDuration(Float videoDuration)
-
getVideoId
final String getVideoId()
-
setVideoId
final Unit setVideoId(String videoId)
-
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
-
-
-
-