Bug 406782 - MediaSession API implementation does not work on youtube
Summary: MediaSession API implementation does not work on youtube
Status: RESOLVED FIXED
Alias: None
Product: plasma-browser-integration
Classification: Plasma
Component: Chrome (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Kai Uwe Broulik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-22 18:57 UTC by appukuttancr
Modified: 2019-04-23 07:36 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description appukuttancr 2019-04-22 18:57:56 UTC
SUMMARY
The mediaSession API shim that's injected currently does not detect the metadata by youtube and youtube music.

STEPS TO REPRODUCE
1. Enable mediasession capability by going to chrome://flags (On chrome 73) 
2. Enable enhanced media controls from extension menu
3. Go to youtube
4. No metadata or enhanced functionilty

OBSERVED RESULT
No metadata on youtube and youtube music

EXPECTED RESULT
Metadata and correct functionality (play pause next prev) on yt and yt music

ADDITIONAL INFORMATION
FIX:
Changing 
https://github.com/KDE/plasma-browser-integration/blob/eb583434a5611e5a3bb8046e6627469753115b3c/extension/content-script.js#L594

to 

${mediaSessionsClassName}.metadata = null;

will fix this problem.

Apparently yt and yt music is checking if metadata is null (?) before applying it's on metadata.
Comment 1 Kai Uwe Broulik 2019-04-23 07:31:19 UTC
Oh, wow! Thank you very much! I was already wondering why YouTube did not support this but never realized they did but checked for this. Indeed changing it to null fixes it.
Comment 2 Kai Uwe Broulik 2019-04-23 07:32:51 UTC
Indeed, I put a breakpoint in the property getter and they do check:
... navigator.mediaSession&&!navigator.mediaSession.metadata&&navigator.mediaSession.setActionHandler&& ...
Comment 3 Kai Uwe Broulik 2019-04-23 07:36:50 UTC
Git commit f4722bd0a6ec63b9e2c05d91d89d1ea58c5581ce by Kai Uwe Broulik.
Committed on 23/04/2019 at 07:34.
Pushed by broulik into branch 'master'.

Initialize metadata with null

This matches Media Session API spec
"A MediaSession has an associated metadata object represented by a MediaMetadata. It is initially null."

M  +1    -1    extension/content-script.js

https://commits.kde.org/plasma-browser-integration/f4722bd0a6ec63b9e2c05d91d89d1ea58c5581ce