Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for looping video playback #460

Closed
markproxy opened this issue Oct 22, 2019 · 5 comments
Closed

Add support for looping video playback #460

markproxy opened this issue Oct 22, 2019 · 5 comments

Comments

@markproxy
Copy link

markproxy commented Oct 22, 2019

According to official YouTube documentation, we should be able to add loop and playlist variables to playerVars to enable automatic looping of video playback: https://developers.google.com/youtube/player_parameters#loop

The android-youtube-player API does not support this, and it would be great if it did.

Note: I have experimented with this locally, by modifying IFramePlayerOptionsExampleActivity and IFramePlayerOptions.kt to send in the loop and playlist variables, and I was unable to get it working. Then I modified WebViewYouTubePlayer.loadVideo() to call "javascript:loadPlaylist('$videoId',0, $startSeconds)" instead of "javascript:loadVideo('$videoId', $startSeconds)", and looping started working. Of course, this also caused the YouTube UI to show an additional control for the playlist (even though there was only one video), so this would not be an acceptable solution.

I'll give some thought to how best to handle the scenario where we want to loop playback on a single video. One option would be for WebViewYouTubePlayer to keep a reference to the IFramePlayerOptions passed into initialize(), and then call loadPlaylist() when the loop option has been set to 1.

@markproxy
Copy link
Author

I'm unable to create a branch to push a commit and open a PR, so I'm attaching a patch file that shows one way to add support for looping, which can be applied locally via git apply patch.txt.

patch.txt

@PierfrancescoSoffritti
Copy link
Owner

Hey, why is it a problem to loop the video manually? (manually restart after it ends)

@markproxy
Copy link
Author

markproxy commented Oct 23, 2019 via email

@PierfrancescoSoffritti
Copy link
Owner

Hey, sorry these days I don't have much time to work on the library. Feel free to send a pull requests, if you have ideas we can discuss them there.

@PierfrancescoSoffritti
Copy link
Owner

This will be available in version 12.1.0 which releases sometimes this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants