Search code examples
chromecast

Is MediaProtocolCommand.Listener onCompleted called when it fails to load a video?


I am on purpose sending a video with a format that is not supported to my receiver app. I see the following message on the chromcast console:

[ 8.188s] [cast.receiver.ChannelOverWebSocket] Sending message: ["ramp",{"cmd_id":1,"type":"RESPONSE","status":{"event_sequence":10,"error":{"domain":"ramp","code":-2}}}] from ws://localhost:8008/session?20

How do I receive that on my android app? I know onComplete for the MediaProtocolCommand.Listener is called when the video plays fine. The description makes it sound like it would also be called when it doesn't play or am I reading that wrong?

I've also tried looking into the MediaProtocolCommand returned by mMessageStream.loadMedia on a separate thread in an infinite loop and it never gets its hasError set to true. So what am I missing?

Thanks.


Solution

  • It appears that the Cast Android SDK isn't parsing these error messages correctly. In the sample Android client, the following exception is thrown with an invalid video URL:

       MediaProtocolMessageStream(9088): error parsing message: 
    {"type":"RESPONSE", "cmd_id":1,"status":{"error":{"domain":"ramp","code":-2},
    "event_sequence":377}} org.json.JSONException: No value for state
    

    This looks like a bug and should be reported to Google.