Answer the question
In order to leave comments, you need to log in
How to use yt api on a page twice?
There is a code:
<div id="player"></div>
<script>var tag = document.createElement('script');tag.src = "https://www.youtube.com/iframe_api";var firstScriptTag = document.getElementsByTagName('script')[0];firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);var player;function onYouTubeIframeAPIReady() {player = new YT.Player('player', {
height: '494', // Высота
width: '878', // Ширина
videoId: "<?php echo $video['popup']; ?>", /* kaR07DuN2T8 */ // ID видео
playerVars: { 'autoplay': 1, 'loop': 1},events: {'onReady': onPlayerReady,'onStateChange': onPlayerStateChange}});}function onPlayerReady(event) {event.target.playVideo();this.id="pl";} function onPlayerStateChange(event) {if (event.data == YT.PlayerState.ENDED ) { event.target.playVideo();}}</script>
<?php if(!isset($lal)){$lal=0;}?>
<div id="player<?php print $lal;?>"></div>
<script>var tag = document.createElement('script');tag.src = "https://www.youtube.com/iframe_api";var firstScriptTag = document.getElementsByTagName('script')[<?php print $lal;?>];firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);var player;function onYouTubeIframeAPIReady() {player = new YT.Player('player<?php print $lal;?>', {
height: '494', // Высота
width: '878', // Ширина
videoId: "kaR07DuN2T8", /* kaR07DuN2T8 */ // ID видео
playerVars: { 'autoplay': 1, 'loop': 1},events: {'onReady': onPlayerReady,'onStateChange': onPlayerStateChange}});}function onPlayerReady(event) {event.target.playVideo();event.target.setVolume(0);this.id="pl";} function onPlayerStateChange(event) {if (event.data == YT.PlayerState.ENDED ) { event.target.playVideo();}}</script>
<?php $lal++;?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question