3
Currently I use the following script to pause youtube video:
HTML:
<span onClick="stopVideo();" class="wmg-close"></span>
<div id="player<?= $dAgenda['id'];?>"></div>
Javascript inside PHP Repeat Loop:
<script type="text/javascript">
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player<?= $dAgenda['id'];?>', {
height: '230',
width: '454',
videoId: '<?= $dAgenda['link'];?>',
events: {}
});
}
function stopVideo() {
player.stopVideo();
}
</script>
Outside of PHP Repeat Loop:
<script type="text/javascript">
// 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
</script>
Completion:
The video is only appearing for the last PHP loop movie!
You can make an example here...I could not find this example in the Youtube API, thank you!
– user3081
I realized this tip you passed, but the video only appears for the last movie, which is (WALL). The other does not appear iframe!
– user3081
I will make an example tonight, because here at work youtube is blocked, you could just update html to facilitate?
– Jeferson Assis
I edited my question there...
– user3081
@user3081follow the example http://jsfiddle.net/kdbgn2qt/
– Jeferson Assis
Use that version, I found a bug in the previous http://jsfiddle.net/kdbgn2qt/1/
– Jeferson Assis