Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="player"></div>
- <script src="http://www.youtube.com/player_api"></script>
- <script>
- // create youtube player
- var player;
- function onYouTubePlayerAPIReady()
- {
- player = new YT.Player('player',
- {
- width: '560',
- height: '315',
- videoId: 'g-JWRqzLZRk',
- events:
- {
- 'onReady': onPlayerReady,
- 'onStateChange': onPlayerStateChange
- }
- });
- }
- // autoplay video
- function onPlayerReady(event)
- {
- event.target.playVideo();
- }
- // when video ends
- function onPlayerStateChange(event)
- {
- if (event.data===0)
- {
- /** here put code to be triggered when video ends ! **/
- }
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement