2011-07-19 16 views
1

私はUIWebViewにYouTube動画を埋め込み、自動再生しています。どうやらこれはうまくいきません。埋め込みYoutubeはUIWebViewでビデオを自動再生しません

http://developer.apple.com/library/safari/#documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/AudioandVideoTagBasics/AudioandVideoTagBasics.html

か、それはバグのいくつかの種類である:これはに関連していますか?

はここに私のhtmlファイルです:

<html> 
    <head> 
     <script> 
      document.ontouchmove=function(e){ e.preventDefault(); }; 

      </script> 
     </head> 
    <body style="margin:0px;" bgcolor="#000000"> 
     <!-- 1. The <div> tag will contain the <iframe> (and video player) --> 
     <div id="player" style="text-align:center;"></div> 

     <script> 
      // 2. This code loads the IFrame Player API code asynchronously. 
      var tag = document.createElement('script'); 
      tag.src = "http://www.youtube.com/player_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 onYouTubePlayerAPIReady() { 
       player = new YT.Player('player', { 
             height: '400', 
             width: '768', 
             videoId: 'HYlD0KXujAk', 
             playerVars: {'autoplay' : 1}, 
             events: { 
             'onStateChange': onPlayerStateChange 
             } 
             }); 
      } 


      // 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) { 
      } 
      function stopVideo() { 
       player.stopVideo(); 
      } 
      </script> 
    </body> 
</html> 
+0

これをどのように解決したか教えてもらえますか? – Cyril

答えて

-1

いいえ、これは何のバグではありません、これはデフォルトの動作です。 UIWebViewは、あなたが(それがデフォルトでYESです)UIWebViewの自分をNOからmediaPlaybackRequiresUserActionプロパティを設定している場合を除き、ユーザーの介入なしに自動的に何も再生されません。その後、それは動作します。

+0

私はNOにプロパティを設定しようとしたが、それは何も変更しませんでした:( –

+0

ありません、私はそれがデフォルトで何だ言わなかっきたあなたがYESに設定する必要があります!!!P – Pripyat

+2

がものを変更しません:( –

関連する問題