Closed Bug 1715415 Opened 3 years ago Closed 3 years ago

Stop Mediakey not working

Categories

(Core :: Audio/Video: Playback, defect, P3)

Firefox 89
defect

Tracking

()

RESOLVED FIXED
91 Branch
Tracking Status
firefox91 --- fixed

People

(Reporter: jz, Assigned: alwu)

References

Details

Attachments

(3 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0

Steps to reproduce:

When playing media on a website the stop-mediakey on my keyboard cannot be used to stop it. The other mediakeys (play/pause, fwd, back) however, do work! The stop key is also working as intended in other programs. Using Chrome also works for websites.

Actual results:

The Windows 10 media control applet is shown for a short time like with all other media-keys, so I think the keypress is registered correctly, however the video continuous to play.

Expected results:

The media playback should stop.

(Note that the function is different from the play/pause button, because pressing play/pause for a second time resumes the playback. Pressing stop for a second time should have no effect. This is a major problem for my setup, because I use my smarthome to stop mediaplayback on certain events. With a working stop-key it works as intended. When I need to use the play/pause function because of the stop-key not working, it only works when there is media playing. If there is no media playing and the smarthome "stops" with the play/pause function, the browser actually starts playback...)

The Bugbug bot thinks this bug should belong to the 'Core::Audio/Video: Playback' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → Audio/Video: Playback
Product: Firefox → Core

Hi jz,

Thanks for the report. What is the website having this problem? The media keys should work with the websites that support MediaSession API (e.g. Youtube). The website can customize the behavior when getting a stop key, so I'd like to know what website you're using.

When you press stop key, is the video paused? or the stop key takes no effect at all? If the website doesn't customize the stop key's behavior via MediaSession API, the default behavior in Firefox is to pause the video.

If the stop takes no effect at all (the video is not paused), could you help us to get the log? The steps are described here. For this bug, please change the command to set MOZ_LOG=timestamp, MediaControl:5. Please upload the logs here when you get it. Thanks!

Severity: -- → S4
Flags: needinfo?(jz)

Hi Chang,

The website in my case was youtube itself. Indeed the stop key has no effect at all. According to Google's official documentation it should work: https://support.google.com/youtube/answer/7631406?hl=en
I also tried with Spotify - same result. Pause/Next/Previous keys work, Stop is ignored.

I would love to generate a log, however the URL provides just gives a "raptor not found". I tried to google the logging options and found instructions to start firefox through a batch file with something like:
set MOZ_LOG=timestamp, MediaControl:5
set MOZ_LOG_FILE=C:\test\mediakeys.log
"C:\Program Files\Mozilla Firefox\firefox.exe"
However, no log file is generated - do I need a specific debug build?

Flags: needinfo?(jz)

Hi,

because I use my smarthome to stop mediaplayback on certain events.

Do you mean using your smart phone? Would you mind to tell me what the application is that you're using to produce the stop media key? Because my keyboard only has play/pause key so I couldn't test that on my keyboard.

You can follow this article and simply use about:networking to dump the log. Use MediaControl:5 in the current log modules.

Thank you.

Flags: needinfo?(jz)

Hi, thanks for getting back to me!

At first: I did mean smart home. My doorbell is sending an event to a node-red instance, which itself is telling a software on my PC to emulate the stop media key. However, this was just to add context and has nothing to do with the actual problem.

For testing purposes I use the normal stop key in my physical Roccat USB keyboard.

Is was able top enable logging with the latest information and I think the results are rather interesting:

Here is the log when using the (working) pause key on a youtube video:

[Parent 272: Main Thread]: I/MediaControl MediaControlKeyManager=260b25de280, playbackState=playing
[Parent 272: Main Thread]: D/MediaControl MediaController=26088a68000, Id=685, Dispatch event playbackstatechange
[Parent 272: Main Thread]: I/MediaControl MediaControlKeyManager=260b25de280, title=Why 4:54 is the perfect speedrun - Super Mario Bros. World Record Speedrun Explained, artist=Bismuth album=
[Parent 272: Main Thread]: D/MediaControl MediaController=26088a68000, Id=685, Dispatch event metadatachange
[Parent 272: Main Thread]: D/MediaControl MediaController=26088a68000, Id=685, Supported keys changes
[Parent 272: Main Thread]: I/MediaControl MediaControlKeyManager=260b25de280, Supported keys=Focus
[Parent 272: Main Thread]: I/MediaControl MediaControlKeyManager=260b25de280, Supported keys=Play
[Parent 272: Main Thread]: I/MediaControl MediaControlKeyManager=260b25de280, Supported keys=Pause
[Parent 272: Main Thread]: I/MediaControl MediaControlKeyManager=260b25de280, Supported keys=Play & pause
[Parent 272: Main Thread]: I/MediaControl MediaControlKeyManager=260b25de280, Supported keys=Stop
[Parent 272: Main Thread]: I/MediaControl MediaControlKeyManager=260b25de280, Supported keys=Seek backward
[Parent 272: Main Thread]: I/MediaControl MediaControlKeyManager=260b25de280, Supported keys=Seek forward
[Parent 272: Main Thread]: D/MediaControl WindowSMTCProvider=260a8b5b240, Update supported keys
[Parent 272: Main Thread]: D/MediaControl WindowSMTCProvider=260a8b5b240, The image is fetched successfully
[Parent 272: Main Thread]: D/MediaControl WindowSMTCProvider=260a8b5b240, The thumbnail is updated to the image from: https://i.ytimg.com/vi/U7RzoIEoSMY/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLBNgC4gC-B6caK4ayJ4lM7gar5inQ
[Parent 272: Main Thread]: D/MediaControl MediaControlKeyHandler=260b22f2490, OnActionPerformed 'Pause'
[Parent 272: Main Thread]: D/MediaControl MediaController=26088a68000, Id=685, Pause

Here is the log when using the stop key instead:

[Parent 272: Main Thread]: I/MediaControl MediaControlKeyManager=260b25de280, title=Why 4:54 is the perfect speedrun - Super Mario Bros. World Record Speedrun Explained, artist=Bismuth album=
[Parent 272: Main Thread]: D/MediaControl MediaController=2607520bc00, Id=653, Dispatch event metadatachange
[Parent 272: Main Thread]: D/MediaControl MediaStatusManager=2607520bc80, SetDeclaredPlaybackState from paused to playing
[Parent 272: Main Thread]: D/MediaControl MediaStatusManager=2607520bc80, UpdateActualPlaybackState : 'playing'
[Parent 272: Main Thread]: D/MediaControl MediaControlKeySource=260a8b5b240, SetPlaybackState 'playing'
[Parent 272: Main Thread]: I/MediaControl MediaControlKeyManager=260b25de280, playbackState=playing
[Parent 272: Main Thread]: D/MediaControl MediaController=2607520bc00, Id=653, Dispatch event playbackstatechange
[Parent 272: Main Thread]: D/MediaControl MediaStatusManager=2607520bc80, Update metadata for session 653 title=Why 4:54 is the perfect speedrun - Super Mario Bros. World Record Speedrun Explained artist=Bismuth album=
[Parent 272: Main Thread]: D/MediaControl MediaStatusManager=2607520bc80, Notify metadata change for active session 653
[Parent 272: Main Thread]: D/MediaControl WindowSMTCProvider=260a8b5b240, Load thumbnail while image: https://i.ytimg.com/vi/U7RzoIEoSMY/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLBNgC4gC-B6caK4ayJ4lM7gar5inQ is being processed
[Parent 272: Main Thread]: D/MediaControl WindowSMTCProvider=260a8b5b240, No need to load thumbnail. The one being processed is in the artwork
[Parent 272: Main Thread]: I/MediaControl MediaControlKeyManager=260b25de280, title=Why 4:54 is the perfect speedrun - Super Mario Bros. World Record Speedrun Explained, artist=Bismuth album=
[Parent 272: Main Thread]: D/MediaControl MediaController=2607520bc00, Id=653, Dispatch event metadatachange
[Parent 272: Main Thread]: D/MediaControl MediaStatusManager=2607520bc80, Update metadata for session 653 title=Why 4:54 is the perfect speedrun - Super Mario Bros. World Record Speedrun Explained artist=Bismuth album=
[Parent 272: Main Thread]: D/MediaControl MediaStatusManager=2607520bc80, Notify metadata change for active session 653
[Parent 272: Main Thread]: D/MediaControl WindowSMTCProvider=260a8b5b240, Load thumbnail while image: https://i.ytimg.com/vi/U7RzoIEoSMY/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLBNgC4gC-B6caK4ayJ4lM7gar5inQ is being processed
[Parent 272: Main Thread]: D/MediaControl WindowSMTCProvider=260a8b5b240, No need to load thumbnail. The one being processed is in the artwork
[Parent 272: Main Thread]: I/MediaControl MediaControlKeyManager=260b25de280, title=Why 4:54 is the perfect speedrun - Super Mario Bros. World Record Speedrun Explained, artist=Bismuth album=
[Parent 272: Main Thread]: D/MediaControl MediaController=2607520bc00, Id=653, Dispatch event metadatachange
[Parent 272: Main Thread]: D/MediaControl WindowSMTCProvider=260a8b5b240, The image is fetched successfully
[Parent 272: Main Thread]: D/MediaControl WindowSMTCProvider=260a8b5b240, The thumbnail is updated to the image from: https://i.ytimg.com/vi/U7RzoIEoSMY/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLBNgC4gC-B6caK4ayJ4lM7gar5inQ
[Parent 272: Main Thread]: D/MediaControl MediaStatusManager=2607520bc80, UpdateMediaPlaybackState started for context 653
[Parent 272: Main Thread]: D/MediaControl MediaPlaybackStatus=2607520bda8, Update playback state 'started' for context 653
[Parent 272: Main Thread]: D/MediaControl MediaStatusManager=2607520bc80, UpdateMediaPlaybackState played for context 653
[Parent 272: Main Thread]: D/MediaControl MediaPlaybackStatus=2607520bda8, Update playback state 'played' for context 653
[Parent 272: Main Thread]: D/MediaControl MediaStatusManager=2607520bc80, SetGuessedPlayState : 'playing'

-> It seems that Firefox isn't registering any buttonpress at all.

However, Windows itself is clearly registering the keypress, since I get the small media control popup window. It also works for other applications including other browsers.

Out of curiousity I also tried a browser-based keyboard event viewer (https://w3c.github.io/uievents/tools/key-event-viewer.html) - it does display the keydown/keyup events on the "MediaStop" key in Firefox just fine...

Flags: needinfo?(jz)

Thank you for your help, I will check this later.

Assignee: nobody → alwu
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3

I can confirm that, I also have a stop button on my keyboard and while the Windows OSD flashes, nothing happens.

Just a heads up: While there is a button "SMTCButton_Stop" that can be translated from, the UpdateButtons and EnableKey facility just does not handle Stop at all (i.e. it's not in the kKeys array), even though there's certainly a way of having a stop button (https://docs.microsoft.com/en-us/previous-versions/windows/desktop/mediatransport/isystemmediatransportcontrols-put-isstopenabled).

The question now would be, why events are happening for disabled buttons (i.e. we never set it to be enabled), but maybe that only influences the appearance in the OSD (pause vs stop button).

So I guess the solution would be to either emulate the stop button event or just add it to the supported keys, not sure where the stop is lost in the chain of Listeners, though, because not setting them as enabled should only be a side effect, unless some facility checks for the allowance of the stop button event and ignores it.

The problem is that we didn't enable the stop key on Windows, so whenever users press stop, SMTC won't receive that key.

Severity: S4 → S3

Depends on D117956

See Also: → 1719753
Pushed by alwu@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/366e7ede4365 part1 : enable the stop button on Windows. r=chunmin https://hg.mozilla.org/integration/autoland/rev/2e34cb1f5b0f part2 : clear the active session Id when stopping a controller. r=chunmin https://hg.mozilla.org/integration/autoland/rev/68c6bb7691ca part3 : modify test. r=chunmin
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: