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

Handle navigator.mediaSession #40

Closed
lethak opened this issue Oct 1, 2020 · 2 comments
Closed

Handle navigator.mediaSession #40

lethak opened this issue Oct 1, 2020 · 2 comments

Comments

@lethak
Copy link
Owner

lethak commented Oct 1, 2020

Ideas:

  • Add previous / skip track controls
  • Custom background...

Read more:

Will not be compatible with IE, Safari and exotic browsers.

Proof of concept code

if ('mediaSession' in navigator) {
    navigator.mediaSession.metadata = new MediaMetadata({
        title: "TITLE",
        artist: "ARTIST",
        album: "ALBUM",
        artwork: [{
            sizes: "320x180",// <- MUST BE EXACTLY!
            src: "https://i.ytimg.com/vi/yAruCvT7P7Y/hqdefault.jpg?sqp=-oaymwEZCNACELwBSFXyq4qpAwsIARUAAIhCGAFwAQ==&rs=AOn4CLAfHWw5BHrQugGsdPYy4eIXcqMTnQ",
            type: ""
        }]
    });

    navigator.mediaSession.setActionHandler('play', function () { });
    navigator.mediaSession.setActionHandler('pause', function () { });
    navigator.mediaSession.setActionHandler('seekbackward', function () { });
    navigator.mediaSession.setActionHandler('seekforward', function () { });
    navigator.mediaSession.setActionHandler('previoustrack', function () { });
    navigator.mediaSession.setActionHandler('nexttrack', function () { });
}```
@lethak
Copy link
Owner Author

lethak commented Oct 3, 2020

This will be included in the next release

Support for browser's Global Media Controls

@lethak lethak closed this as completed Oct 14, 2020
@lethak
Copy link
Owner Author

lethak commented Oct 14, 2020

Implemented in v2020.10.642

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant