2014-02-13 3 views
0

작동하지? 그 다음 난 그냥 검은 화면을 얻을, 재생 시작할 것처럼 Fancybox YouTube는 어떤 아이디어 왜, 내가 공식 Fancybox 유튜브 구현 JSfiddle는 iOS에서 작동하지 않는 것을 알 아이 패드 또는 아이폰

http://jsfiddle.net/M78zz/show/

// Fires whenever a player has finished loading 
function onPlayerReady(event) { 
    event.target.playVideo(); 
} 

// Fires when the player's state changes. 
function onPlayerStateChange(event) { 
    // Go to the next video after the current one is finished playing 
    if (event.data === 0) { 
     $.fancybox.next(); 
    } 
} 

// The API will call this function when the page has finished downloading the JavaScript for the player API 
function onYouTubePlayerAPIReady() { 

    // Initialise the fancyBox after the DOM is loaded 
    $(document).ready(function() { 
     $(".fancybox") 
      .attr('rel', 'gallery') 
      .fancybox({ 
       openEffect : 'none', 
       closeEffect : 'none', 
       nextEffect : 'none', 
       prevEffect : 'none', 
       padding  : 0, 
       margin  : 50, 
       beforeShow : function() { 
        // Find the iframe ID 
        var id = $.fancybox.inner.find('iframe').attr('id'); 

        // Create video player object and add event listeners 
        var player = new YT.Player(id, { 
         events: { 
          'onReady': onPlayerReady, 
          'onStateChange': onPlayerStateChange 
         } 
        }); 
       } 
      }); 
    }); 

} 

fancybox가 열립니다

http://jsfiddle.net/M78zz

, 다음, 유튜브 비디오 부하 및 보인다. 이것은 iPhone과 iPad 모두에서 발생합니다.

아무도 도와 줄 수 있습니까?

+0

[Fancybox - 비디오 자동 닫기 기능]의 중복 가능성 (http://stackoverflow.com/questions/20855414/fancybox-video-auto-close-function) – JFK

+0

귀하의 의견을 바탕으로, 내가 그랬어 특히, iOS에서 유튜브가'event.target.playVideo()을 좋아하지 않는 것 http://stackoverflow.com/a/20863405/1055987 이유를 설명 내 대답에 편집,'비디오가로 변환되기 전에 실행되는 HTML5 형식 – JFK

답변

0

이 질문은 꽤 많이 올 것 같습니다. 모바일 사파리에서는 자바 스크립트가 자동 재생이나 태그의 재생을 프로 그램으로 시작할 수 없기 때문에 문제가 발생했을 가능성이 큽니다 플래시가 없으면 YouTube가 동영상을 제공하는 방식입니다.) 오히려, 모바일 사파리는 재생 (아마도 그래서 사용자가 의도하지 않고 셀룰러 데이터를 사용하지 않습니다)를 시작해야하는 사용자가 필요합니다. fancybox가 프로그램 재생에 의존하는 경우

따라서 (즉 event.target.playVideo())는 모바일 사파리와 호환되지 않는다.

More info