4

How to change the volume / mute the stream audio without using the controls on the cast extension ? I have implemented a slider on the sender side . This passes the volume value to receiver . But I do not understand , how to set volume or mute/ unmute command is send from the receiver app to the player. What APIs should I use for this?

Zer0
  • 448
  • 1
  • 5
  • 16

3 Answers3

2

I was able to find/reverse-engineer it. I haven't found this in the documentation though.

cast.framework.CastReceiverContext.getInstance().setSystemVolumeLevel(0.5) // 50%
jukben
  • 1,088
  • 7
  • 16
0

You could set the volume directly of the HTML media element.

If you have a custom player, you should be able to set the player volume: https://developers.google.com/cast/docs/reference/receiver/cast.receiver.media.Player#setVolume

Leon Nicholls
  • 4,623
  • 2
  • 16
  • 17
0

You can use:

 var playerContext = cast.framework.CastReceiverContext.getInstance();
 var playerManager = this.playerContext.getPlayerManager();
 var volumeRequest = new cast.framework.messages.VolumeRequestData();
 volumeRequest.volume.level = level; // 0 - 1
 playerManager.sendLocalMediaRequest(volumeRequest);`

But the volume bar doesn't show. I don't know why.

Jess Bowers
  • 2,846
  • 1
  • 22
  • 42