2013-09-03 2 views
3

YouTube 수신기를 사용하지 않고 Chromecast에서 YouTube 동영상을 재생하려고하지만 iframe YouTube API 만 사용하면됩니다. 수신자 URL이 데스크톱 크롬 브라우저에로드되면 괜찮아요.하지만 동일한 URL이 Chromecast에로드되면 '이 동영상은 현재 사용할 수 없습니다 - 자세히 알아보기'라는 메시지가 표시됩니다. 한 번 제작 된 위젯을 계속해서 다른 동영상을 재생하려고하면 '어도비 플래시 플레이어가 동영상 재생에 필요합니다'라고 표시되는 경우가 있습니다.Chromecast의 YouTube iframe API 동작

위젯은 문서에 표시된대로 새로운 YT.Player를 사용하여 onYouTubeIframeAPIReady() 콜백에 만들어집니다. 어쩌면 혼란 스러울 지 모르겠지만 iframe API는 플래시 기반이 아닌 html5 기반이라고 생각했습니다. 누구든지 성공적으로이 작업을 수행 했습니까? 아니면 Chromecast에서 지원되지 않으므로 이상한 행동입니까? 나는 또한 이것에 우연히 만났습니다 http://www.youtube.com/html5

+0

iFrame API를 사용하는 수신기를 성공적으로 만들었으며 아직 시도한 동영상에 문제가 없었습니다. 어떤 비디오 ID로 오류가 발생 했습니까? 따라서 리시버에서 해당 비디오 ID를 시도해 볼 수 있습니다. 성공한 경우 코드를 대답으로 공유 할 수 있습니까? – jlmcdonald

+0

나는 하나 하나 시도했다. 예를 들어, youtube api의 참조 예 - 'M7lc1UVf-VE' – milleph

+0

하지만 설정/초기화 만하면됩니다. 만약 당신이 매우 도움이 될 몇 가지 코드를 게시 할 수 있습니다. – milleph

답변

6

다음은 현재 수신기에서 사용중인 코드입니다. 메시지 핸들링 (양방향)은 실패하고, 놓치고, 나는 그것을 통해 현재 작업하고 있습니다 ...하지만 iFrame 라이브러리의 로딩, 비디오의 임베딩 등은 모두 작동합니다. 귀하의 목적에 맞지 않을 경우 귀하의 설정이 어떻게 다른지 조사 할 수 있습니다. 나는 그것이 도움이 될만한 의견을 추가하려고 노력했다.

<html> 
<head> 
<script src="https://www.gstatic.com/cast/js/receiver/1.0/cast_receiver.js"> 
</script> 
<script type="text/javascript"> 
// first create our receiver object and our channel handler 
     var receiver = new cast.receiver.Receiver('{YOUR_APP_ID}', ['ChromecastYoutube'],"",5); 
     var ytChannelHandler = new cast.receiver.ChannelHandler('ChromecastYoutube'); // 'using 'ChromecastYoutube' as my dev namespace. Wouldn't really be that in production. 
     ytChannelHandler.addChannelFactory(receiver.createChannelFactory('ChromecastYoutube')); 
     ytChannelHandler.addEventListener(
       cast.receiver.Channel.EventType.MESSAGE, 
       onMessage.bind(this) 
     ); 

     receiver.start(); 

     window.addEventListener('load', function() { // we won't try to load the iframe libraries until the chromecast window is fully loaded. 
       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: '562', 
         width: '1000', 
         videoId: 'jLlSqucqXB0', 
         playerVars: { 'autoplay': 0, 'controls': 0 }, 
         events: { 
           'onReady': onPlayerReady, 
           'onPlayerStateChange': onStateChange 
         } 
       }); 
     } 

     function onPlayerReady(event) { 
       document.getElementById('annotation').innerHTML="We're ready to go"; 
     } 

     function onStateChange(event) { 
       switch (event.data) { 
         case YT.PlayerState.ENDED: 
           // TODO let sender know we're done, then close casting 
           break; 
         case YT.PlayerState.PLAYING: 
           // TODO let sender know we're playing 
           break; 
         case YT.PlayerState.PAUSED: 
           // TODO let sender know we're paused 
           break; 
       } 
     } 

     function onMessage(event) { // currently, any one of these will work, but subsequent ones seem to falter. Investigating... 
       ytBindings={"playVideo":player.playVideo(),"pauseVideo":player.pauseVideo(),"stopVideo":player.stopVideo(),"getStatus":player.getPlayerState()} 
       ytBindings[event.message]; 
     } 


</script> 
<style> 
#wrapper { 
     width: 1000px; 
     margin: 10px auto; 
     text-align: center; 
} 
#annotation { 
     color: #ffffcc; 
     font-size: 200%; 
     margin-top:25px; 
} 
</style> 
</head> 
<body> 
<div id="wrapper"> 
<div id="player"></div> 
<div id="annotation"></div> 
</div> 
</body> 
</html> 
+0

하나만 제외하고는 모든면에서 광산과 비슷합니다. 먼저 SoundCloud 위젯을 설치하고 iframe에도 설정 한 다음 자연히 같은 페이지에 YouTube iframe을 추가했습니다. 공존 할 수없는 것 같지만 왜 그런지는 모르겠습니다. SoundCloud 위젯을 제거하면 동영상이 정상적으로 재생됩니다. 당신이 그렇게 경사 느끼면 다음이 추가 ... \t \t – milleph

+0

더 복잡하고 추가 iframe과 관련이 없을 수도 있습니다. YouTube iframe을 사용하면 초기에 사용했던 일련의 동영상 ID에서 작동했지만 다음 ID 중 하나에서 플래시 오류가 발생합니다 .... ktvTqknDobU, 5NV6Rdv1a3I, e9SeJIgWRPk – milleph

+0

모든 Vevo 동영상입니다.유감스럽게도 Vevo (및 음악과 관련이있는 다른 일부 컨텐츠 제공 업체)는 비디오에 제한을 두어 완전히 내장 할 수 없거나 Flash Player 등에 포함시킬 수 있습니다. HTML5 퍼가기를 사용하면 Flash 임베드 (기본적으로 iFrame이 기본 임)로 설정되며 Chromecast에 플래시 플레이어가 없기 때문에 오류가 발생합니다. HTML5 모드를 강제 실행하려고하면 삽입 할 수 없다는 오류 150이 표시됩니다. – jlmcdonald

0

현재 동작 : Chromecast 설정 중에 Chromecast 펌웨어 16041 및 국가 코드가 올바르게 설정되어있는 것으로 보입니다. 여기에 최신 코멘트 https://code.google.com/p/gdata-issues/issues/detail?id=5923

이전 답변을 참조하십시오 : 가 여기에 문제의 근본 원인입니다 : https://support.google.com/chromecast/answer/2995235?hl=en 일부 동영상은 Chromecast를 사용하여 재생되지 않을 수 있습니다. 비공개 동영상, 라이브 콘텐츠 및 모바일 재생이 승인되지 않은 동영상은 Chromecast에서 작동하지 않습니다. 이 변경되어 기본 Chromecast 사용 사례가 삭제되기를 바랍니다.

+0

시도해 볼 것을 요청하는 중 .... 나는 Vevo 비디오가 삽입 할 수 없기 때문에 Chromecast에서 재생되지 않을 것이라고 추정했습니다. iframe youtube 플레이어의 경우 확실히 그렇습니다. 그러나 Android YouTube 앱은 문제없이 (그리고 광고없이) 전송할 수 있습니다. 분명히 Google은 할 수없는 일을 할 수 있지만 iframe 위젯 대신 YouTube 수신자를 사용하도록 전환하면 문제가 해결 될 것이라고 생각합니까? – milleph

+0

업데이트 된 답변보기 Chromecast Youtube 제한이 해제 된 것 같습니다. – Mark

+0

감사합니다. – milleph

0

또한이 문제가 발생하여 비디오가 시작되기 직전에 html5 오디오를 사용하여 사운드 효과를 재생할 수있는 원인이 발견되었습니다. 음향 효과를 제거하면 YouTube 플레이어가 다시 작동합니다.