0

Android and iOS have a setPlaybackRate method, but the Web Sender API doesn't have this. How can I accomplish this using sendMessage? Is it something like this? But what is the type of message?

playerTarget.setHalfSpeed = function (){
    var media = castSession.getMediaSession();
    castSession.sendMessage("urn:x-cast:com.google.cast.media",{
        type: "THEWHATNOW",
        playbackRate: 0.5,
        mediaSessionId: media.mediaSessionId
    });
}.bind(this);

I see messages listed here: https://developers.google.com/cast/docs/reference/messages but then in the examples I see a message type of "SKIP_AD" which isn't documented anywhere. All I want to be able to do is set the playback rate during playback when casting as a websender.

I see the message type here: https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.messages.SetPlaybackRateRequestData But what is the namespace for that to send in the sendMessage call?

Jay
  • 36
  • 5

2 Answers2

0

For anyone else who stumbles upon this, here is what worked for me:

playerTarget.setHalfSpeed = function (){
    var media = castSession.getMediaSession();
    castSession.sendMessage("urn:x-cast:com.google.cast.media",{
        type: "SET_PLAYBACK_RATE",
        playbackRate: 0.5,
        mediaSessionId: media.mediaSessionId,
        requestId: 2
    }).then(
        function (a) { console.log('Set playback rate success'); },
        function (errorCode) {
            console.log('Set playback rate error: ' + errorCode);
        });
}.bind(this);

The requestId doesn't seem to matter as its a transit variable.

Jay
  • 36
  • 5
0

jay's answer worked

I could also do it from

const PLAYBACK_RATE = {
  NORMAL: 1,
  //1.25x
   FAST: 1.25,
  //1.5x
  FASTER: 1.5,
  //1.75x
  FASTEST: 1.75,
  //2x
   DOUBLE: 2

 };

let request = new chrome.cast.media.LoadRequest(mediaInfo);
request.currentTime = this.currentMediaTime;
//playbackRate
request.playbackRate = PLAYBACK_RATE.FASTER; //playbackRate playback speed
Jpabon
  • 1
  • 1