Load video playing previous video
See original GitHub issueUsing version: 8.0.1
if youtubeArray.isEmpty {
youtubeArray.populate with videos. Array with 5 string videoIds
} else {
var randomVid: String = youtubeArray[Random().nextInt(youtubeArray.size)]
loadVideo(playerview, randomVid)
val randomVidIndex = youtubeArray.indexOf(randomVid)
youtubeArray.removeAt(randomVidIndex)
}
YouTube.loadvideo
fun loadVideo(playerView: YoutubePlayerView, videoId: String) {
playerView.initialize({ initializedPlayerView ->
initializedPlayerView.addListener(object: AbstractYouTubePlayerListener() {
override fun onReady() {
super.onReady()
initializedPlayerView.loadVideo(videoId, 0f)
System.out.println("Playing Video: $videoId")
}
}
})
}, true)
As you can see in the code above i am trying to call random videos from an array. This works, but only once. It fetched a video and played it. When I click the button again, instead of playing a different video, it plays the same one again. With System.out.println("Playing Video: $videoId")
I can see the player attempting to play another video, but changes and plays the previously played video. Any ideas on the culprit of this?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
HTML5 video previous - next and auto play - Stack Overflow
First step is to add an event handler to each button. For example, something like this should work for your next button. var...
Read more >Lazy-loading video - web.dev
This post explains lazy-loading and the options available to you when lazy-loading video.
Read more >How to preload an entire html5 video before play, SOLVED
Solution #4, ajax and bloburl (works) ... You can force the browser to download a video by making a GET request to the...
Read more >HTMLMediaElement.load() - Web APIs - MDN Web Docs
The HTMLMediaElement method load() resets the media element to its initial state and begins the process of selecting a media source and loading...
Read more >YouTube Player API Reference for iframe Embeds
The IFrame player API lets you embed a YouTube video player on your website and control the player using JavaScript. Using the API's...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kunwarshekhar You can:
I tried that but the issue is little different, can you check this: https://github.com/PierfrancescoSoffritti/android-youtube-player/issues/378