I created a custom receiver for Chromecast that plays video and I am trying to send messages back to my Android sender app on the same namespace. I'm currently doing it this way in Javascript:
window.castReceiverManager = cast.receiver.CastReceiverManager.getInstance();
window.castReceiverManager.start();
//use namespace urn:x-cast:com.google.cast.media to communicate to VideoCastManager in Android...?
window.customMessageBus = castReceiverManager.getCastMessageBus('urn:x-cast:com.google.cast.media', cast.receiver.CastMessageBus.MessageType.JSON);
//overwrite the onMessage function
var defaultFunction = window.customMessageBus.onMessage;
window.customMessageBus.onMessage = function(event) {
window.senderId = event.senderId;
window.message = event.data;
defaultFunction(event);
};
//send message
window.customMessageBus.send(window.senderId, {message: "test"});
In Android, I am trying to receive the messages in this way:
mCastConsumer = new VideoCastConsumerImpl() {
//removed all the other override functions to save space
@Override
public void onDataMessageReceived(String message) {
System.out.println("CAST RECEIVED MESSAGE:" + message);
}
};
This doesn't work, and I was hoping someone could point me in the right direction?
Thanks
You need to use a custom namespace not the Media namespace.