Napster
Napster

Reputation: 1

How can we restrict Youtube player forward seek in Android using YoutubePlayer API?

While playing videos in YouTube player I need to restrict the user from seeking forward but he can seek backward. How can we achieve this? Thanks.

Upvotes: 0

Views: 621

Answers (1)

Dmitriy Mitiai
Dmitriy Mitiai

Reputation: 1200

YoutubePlayer API has not this possibility, but you can do the trick. The logic is next: you can listen the played position of the player with mYouTubePlayer.getCurrentTimeMillis() and remember the last played position. When user will make the seek, you should calculate the difference between last played position and getCurrentTimeMillis(). And if difference more than needed time, just set the maximum available time to seek by mYouTubePlayer.seekToMillis(max_available_time_to_seek)

Upvotes: 2

Related Questions