beefweb icon indicating copy to clipboard operation
beefweb copied to clipboard

Added MediaSession support (notification controls on mobile)

Open R0nd opened this issue 5 years ago • 6 comments

Implemented MediaSession support (show playing track and expose playback controls in a notification on mobile). Works great in Chrome, somewhat buggy in Firefox Nightly for now (no prev/next buttons, incorrect playback state). image

R0nd avatar Oct 03 '20 19:10 R0nd

One ugly hack I had to add is an <audio> tag with a 5-second silent mp3 file, because the current MediaSession API spec draft requires an html audio/video to be playing for it to work, and audio files shorter than 5 seconds don't count? I hope the final version of the spec makes more sense.

R0nd avatar Oct 03 '20 19:10 R0nd

@R0nd, Thank you for the contribution, the idea looks very promising. I've left few improvement suggestions.

hyperblast avatar Oct 04 '20 10:10 hyperblast

One ugly hack I had to add is an <audio> tag with a 5-second silent mp3 file, because the current MediaSession API spec draft requires an html audio/video to be playing for it to work, and audio files shorter than 5 seconds don't count? I hope the final version of the spec makes more sense.

This has possible unintended effect effect of draining mobile battery for playing silence. I think it's fine to keep this as that for now, probably makes sense to add setting to disable this feature completely. I could help you with that.

hyperblast avatar Oct 04 '20 10:10 hyperblast

I think it's fine to keep this as that for now, probably makes sense to add setting to disable this feature completely.

I've added a setting to enable this feature. I've made it disabled by default, since there's no data on performance impact yet and browser support isn't 100% there.

R0nd avatar Oct 04 '20 20:10 R0nd

@R0nd sorry for delay, I'm on vacation at the moment, would merge it when I'm back, have a nice day!

hyperblast avatar Oct 13 '20 10:10 hyperblast

I've added a setting to enable this feature. I've made it disabled by default, since there's no data on performance impact yet and browser support isn't 100% there.

Probably it would be better to avoid <audio> completely if setting is disabled.

Brace formatting still does not match other source files: { should be on the next line for control statements and declarations, for object expressions could be on the same line. Short example of the described style.

hyperblast avatar Oct 13 '20 10:10 hyperblast