Recently, YouTube introduced the new Autoplay feature and I got jealous.
I implemented it on my tube site. My site uses jwplayer as a video player, it has a very beautiful and easy API where a function there is called onComplete, where it will execute my javascript queries at the end of the video.
What I did is this:
onComplete:function() {
//Video has ended, now we redirect to the new video
window.location.href = "//www.mysite.com/video?id=33412";
}
So, using this, my site will successfully redirect to a new video, and so on. But, what if the user turns off the "Autoplay" feature as shown in the image. How can I disable the window.location.href?
Other stackoverflow answers said:
You can't change the window.location prototype, because this a "native property" of window and it is not configurable.
What would be the solution in my case? A solution using Jquery is okay for me too.
For autoplay
have a flag. Set/unset the flag.
In your onComplete, check the flag
onComplete:function() {
//Video has ended, now we redirect to the new video
// check the flag and execute
if(autoPlay) window.location.href = "//www.mysite.com/video?id=33412";
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments