2017-04-05 8 views
0

수신기 애플리케이션에서 전송 메시지 버스를 초기화하려고합니다. CastReferencePlayer Sample (https://github.com/googlecast/CastReferencePlayer) 시작시 채널을 초기화 할 수 있으며 은 하나의 메시지를 수신합니다.Chromecast가 CastMessageBus에서 메시지를받지 못합니다.

하지만 미디어를 재생 한 후에 의 동일한 send 방법을 사용하여 채널을 통해 추가 메시지를받을 수 없습니다. 내 발신자는 iOS Device

채널이 앱 수명 기간 동안 열려 있는지 확인하기 위해 메시지 버스를 초기화하는 가장 좋은 장소는 어디입니까?

채널 을 (를) sampleplayer.CastPlayer.prototype.start = function() (으)로 현재 시작합니다. 그러나 시작시 (예 : 미디어가 재생되기 전에) 한 번만 메시지를 수신 할 때 메시지 버스를 시작할 올바른 위치인지 여부는 확실하지 않습니다.

sampleplayer.CastPlayer.prototype.start = function() { 
 
     var messageBus = this.receiverManager_.getCastMessageBus(
 
      "urn:x-cast:com.myTestChannel.app", 
 
      cast.receiver.CastMessageBus.MessageType.JSON); 
 
    
 
     messageBus.onMessage = function(event) { 
 
      var message = event.data; 
 
      if (message.testID) { 
 
       console.log("Message received"); 
 
      } else if (message.someKey) { 
 
       console.log("pause message received"); 
 
      } 
 
      }; 
 
      this.receiverManager_.start(); 
 
     };

(단, 즉 초기 메시지) 내 player.js 내부 window.onload 함수 채널 생성 코드를 배치하는 시도했지만이 이전과 동일하게 반응한다.

채널 초기화를 위해 코드를 배치해야하는 사람이 있습니까? 도움이 될 것입니다.

EDIT : 더 조사를 해본 결과 수신자에게 여러 개의 메시지를 보내지 않는 것은 내 iOS 발신자임을 알게되었습니다. 나는 안드로이드와 크롬을 시험해 보았고 여러 메시지가 작동합니다. iOS 발신자가 보내는 메시지에 문제가 있음을 알 수 있습니까?

+0

[SO 게시물] (http://stackoverflow.com/questions/39766944/sending-a-json-from-ios-sender-to-receiver-app-with-the-googlecast-sdk- v3), 네임 스페이스에 대해 [GCKCastChannel] (https://developers.google.com/cast/docs/reference/ios/interface_g_c_k_cast_channel#a536d42cdcastb9d56d9ed10c3f75c493985) 인스턴스를 만들고 ['sendTextMessage']를 사용해야합니다. (https://developers.google.com/cast/docs/reference/ios/interface_g_c_k_cast_channel#a536d42cdfb9d56d9ed10c3f75c493985). – abielita

+0

@abielita, 링크 주셔서 감사합니다. 올바른 네임 스페이스에 캐스트 채널을 이미 만들었습니다. 나는 나의 문제를 해결했다. 구현시 처음 캐스트 채널을 사용한 후 캐스트 채널에 대한 참조가 삭제되었습니다. – mhorgan

답변

0

내 코드의 문제점이 내 보낸 사람에게 있습니다.

sendTextMessage 메서드는 캐스트 채널에 대한 참조가 소멸되어 첫 번째 인스턴스 이후에 실행되지 않았습니다.