javascript - How to access event "onplay()" for iframe? -


i have 2 iframes in 1 page.

<iframe id="video" width="420" height="315" src="//www.youtube.com/embed/9b7te184zpq?rel=0" frameborder="0" allowfullscreen></iframe> <iframe id="video1" width="420" height="315" src="//www.youtube.com/embed/9b7te184zpq?rel=0" frameborder="0" allowfullscreen></iframe> 

i want access onplay() event of iframe, can able stop second video(#video1) while playing first one(#video) , stop first video(#video) when playing second(#video1).

it possible using youtubeapi not want use because have other url videos not youtube videos(here put youtube links instead orignal links avoid copyright). there way except youtubeapi. youtubeapi not working on link resources. please suggest.

it has 2 <iframe>. first, need switch between iframe.

is there way change context iframe in javascript console?

after, here code how access event onplay() of <iframe>

<script src="https://www.youtube.com/iframe_api"></script>    <div class="module module-home-video">      <span class="module-strip">latest product video</span>      <div id="video"></div>  </div>    <script>      var player, playing = false;      function onyoutubeiframeapiready() {          player = new yt.player('video', {              height: '360',              width: '640',              videoid: 'xmhtv4270nu',              events: {                  'onstatechange': onplayerstatechange              }          });      }        function onplayerstatechange(event) {          if(!playing){              alert('onplay clicked');              playing = true;          }      }  </script>


Comments