2017-05-26 11 views
1

埋め込み動画のタグを<object>に使用しています。私は<object>タグ実装でフルスクリーンモードを必要とするいくつかのレガシーコードを持っています。どういうわけか<object>タグでネイティブフルスクリーンモードを強制することはできますか?youtube埋め込みビデオオブジェクトタグ付きフルスクリーン

<object 
    width="560" 
    height="350" 
    data="http://www.youtube.com/v/B8IIyYpqb5w&amp;fs=1" 
    type="application/x-shockwave-flash"> 

    <param name="wmode" value="opaque" /> 
    <param name="allowFullScreen" value="true" /> 
    <param name="src" value="http://www.youtube.com/v/B8IIyYpqb5w&amp;fs=1" /> 
</object> 

私も&fs=1&fullscreen=1 URL内のパラメータが、運を試してみました。

答えて

0

残念ながら、代わりにを使用する必要があります。 w3schoolsに従って、<object>および<embed>のこの制限が2015年1月から廃止されました。このスニペットに

ベース:

<body> 

<div> 
    <object 
    type="application/x-shockwave-flash" 
    data="http://www.youtube.com/v/Wd1Iz6j4WC0" 
    width="425" 
    height="355"> 
    <param name="movie" value="http://www.youtube.com/v/Wd1Iz6j4WC0"> 
    <param name="allowFullScreen" value="true"></param> 
    </object> 
</div> 

<iframe src="//www.youtube.com/embed/Wd1Iz6j4WC0" width="640" height="360" frameborder="0" allowfullscreen="allowfullscreen"></iframe> 


</body> 

オブジェクトタグが意図したとおりにIFRAME機能ながら、「フルスクリーンが利用できない」経験し続けます。

それとも、これを使用することができます:

<!DOCTYPE html> 
<html> 
    <body> 
    <!-- 1. The <iframe> (and video player) will replace this <div> tag. --> 
    <div id="player"></div> 

    <script> 
     // 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); 

     // 3. This function creates an <iframe> (and YouTube player) 
     // after the API code downloads. 
     var player; 
     function onYouTubeIframeAPIReady() { 
     player = new YT.Player('player', { 
      height: '390', 
      width: '640', 
      videoId: 'M7lc1UVf-VE', 
      events: { 
      'onReady': onPlayerReady, 
      'onStateChange': onPlayerStateChange 
      } 
     }); 
     } 

     // 4. The API will call this function when the video player is ready. 
     function onPlayerReady(event) { 
     event.target.playVideo(); 
     } 

     // 5. The API calls this function when the player's state changes. 
     // The function indicates that when playing a video (state=1), 
     // the player should play for six seconds and then stop. 
     var done = false; 
     function onPlayerStateChange(event) { 
     if (event.data == YT.PlayerState.PLAYING && !done) { 
      setTimeout(stopVideo, 6000); 
      done = true; 
     } 
     } 
     function stopVideo() { 
     player.stopVideo(); 
     } 
    </script> 
    </body> 
</html> 

サンプルHTMLページは、以下のビデオをロードする6秒のためにそれを再生して、再生を停止します埋め込み型プレーヤーを作成します。

このヘルプが必要です。

関連する問題