Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle media.setPlaybackRate for desktop compatibility #64

Open
Lindsay-Needs-Sleep opened this issue May 25, 2020 · 0 comments
Open
Labels
question Further information is requested

Comments

@Lindsay-Needs-Sleep
Copy link
Collaborator

Lindsay-Needs-Sleep commented May 25, 2020

Terminology

desktop/cdv devs: devs who write a hosted app that runs on both cordova apps and on desktop browsers

Why am I asking this question

This question arose when looking into PR #63.

The PR will add the function chrome.cast.media.setPlaybackRate.

Unfortunately, media.setPlaybackRate doesn't exist in the official Google Cast API for Chrome.

This is a problem for hosted cordova apps that run on both cordova apps and in desktop chrome.

Currently, you can use the exact same script to control a chromecast on cordova and on desktop chrome. Which is super convenient.
(Aside from functions under chrome.cast.cordova, these functions supply operations that are impossible in the browser, and should be isolated to that).
Adding media.setPlaybackRate would break this.

This functionality is possible in chrome desktop via:

session.sendMessage(
    "urn:x-cast:com.google.cast.media", 
    {
        mediaSessionId: session.media[0].mediaSessionId, 
        requestId: 12345, 
        type: 'SET_PLAYBACK_RATE',
        playbackRate: 1
    }, 
    function () {
        console.log('success');
    }, function (err) {
        console.log(err);
    });

Actual Question

How do we handle this situation while inconveniencing the desktop/cdv devs minimally?

Options

Here's what I can think of so far:

  1. Drop media.setPlaybackRate and only use sendMessage. Add a documentation note on how to set playback rate with sendMessage.
    • Requires users to use a really ugly piece of code.
    • Requires ugly documentation.
    • (4th imo)
  2. Keep media.setPlaybackRate and add a note that this is a cordova exclusive function.
    • Requires desktop/cdv devs to write conditional code.
    • Requires some ugly documentation, but only targeted at desktop/cdv devs
    • (2nd imo)
  3. Rename it to chrome.cast.cordova.setPlaybackRate.
    • Doesn't fit with the rest of the cordova exclusive functions.
    • Is actually possible to do on browser, so shouldn't exactly be cordova exclusive.
    • Requires desktop/cdv devs to write conditional code.
    • Requires some special documentation.
    • (3rd imo)
  4. Make a file, "cast-convenience-functions.js" (or something), that has media.setPlaybackRate which just calls the built sendMessage function. Add a note for desktop-compatibly-hosted-web-app that they must include a copy of this file on their site to be able to use media.setPlaybackRate.
    • desktop/cdv devs have to add a file to their website
    • Requires documentation targeted at desktop/cdv devs
      • But will only need to add this note once eg. media.setPlaybackRate*, * points to note they need to add file
    • desktop/cdv devs will need to update the file if they update the plugin and want to use new convenience functions.
      • completely non-cordova devs can use this file as well
    • (best imo)

Conclusion

I like option 4 the best atm.

I would prefer to keep my chromecast controlling script as clean as possible. Currently, it doesn't even mention cordova once, I would like to keep it that way.

But I would like to hear any feedback about this issue/idea. Particularly from other desktop/cdv devs. But all welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Development

No branches or pull requests

1 participant