2
votes

I need to draw in UI a proper volume level on client (sender) side when working with Chromecast Audio. I see there are two ways of receiving (and might setting as well) volume from Chromecast - from Receiver and Media namespaces. In my understanding Receiver namespace stores general device's volume while Media namespace stores volume of currently played track.

  1. It seems that I can't receive media volume by using GET_STATUS request for Media namespace before I load any tracks with LOAD request. Then how do I correctly display volume that will be used before loading media? Changing in UI RECEIVER volume to MEDIA volume after media is loaded doesn't look like a good solution and will be a surprise for users.
  2. I fail to control volume using SET_VOLUME request for Receiver namespace - I've got no reply from Chromecast

    Json::Value msg, response;
    msg["type"] = "SET_VOLUME";
    msg["requestId"] = ++request_id;
    msg["volume"]["level"] = value; // float
    response = send("urn:x-cast:com.google.cast.receiver", msg);
    

    If the following lines are used instead of the last one, media volume is controlled OK:

    msg["mediaSessionId"] = m_media_session_id;
    response = send("urn:x-cast:com.google.cast.media", msg);
    

    What am I doing wrong here?

1

1 Answers

2
votes

In order to set the volume on the receiver, you should be using the SDK's APIs instead of sending a hand-crafted message. For example, you should use setReceiverVolumeLevel(). Also, use the receiver volume and not the stream volume.