Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting Youtube video state from JavaScript

Is there a way of detecting when a Youtube Video has finished playing from JavaScript?

like image 891
Allain Lalonde Avatar asked Jun 08 '09 17:06

Allain Lalonde


People also ask

How do I know if my video is playing JavaScript?

log("video is playing"); //DO SOMETHING... } You can use the . paused() method in javascript to check whether a video is playing or not. It will return true if the video is playing and return false if the video is not playing.

Does YouTube run on JavaScript?

Normal use of YouTube involves use of nonfree software. In the HTML5 mode, it involves running a nonfree JavaScript program. For some videos, it also requires the nonfree Adobe DRM software that has been incorporated into proprietary browsers and Firefox, but not into the GNU browsers including IceCat.

Can you play videos with YouTube API?

The IFrame player API lets you embed a YouTube video player on your website and control the player using JavaScript. Using the API's JavaScript functions, you can queue videos for playback; play, pause, or stop those videos; adjust the player volume; or retrieve information about the video being played.


2 Answers

Sure can - using the javascript API for youtube

like image 75
Matt Avatar answered Sep 30 '22 16:09

Matt


You should be able listen to the onStateChange event.

Check out the API Reference

like image 32
Joseph Avatar answered Sep 30 '22 15:09

Joseph