jquery - Listen to youtube iframe events using javascript -


i have site list of many embedded youtube videos this

 <div class="thumbnail">           <iframe width="560" height="315" src="https://www.youtube.com/embed/2szaexbp0ne" frameborder="0" allowfullscreen></iframe> </div> 

the video list big , changing daily.

im looking way capture start video event, can force user accept tos (using popup) before seeing videos. tried place div higher z-index , put onclick event there ,but not working/preventing user watch video.

so ended using youtube api few things mention

you must use div placeholder video this

<div id="video3" class="video3"></div> 

and may declare callback function fires once video clicked

function onyoutubeiframeapiready() {     video1 = new yt.player('video1', {       height: '315',       width: '560',       videoid: 'youtubeid',       events: {         'onstatechange': onplayerstatechange       }     }); 

note videos must loaded inside onyoutubeiframeready , may point same callback function or different ones hope helps


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -