Closed Bug 1575995 Opened 5 years ago Closed 5 years ago

Use Mac's hardware media keys to control media

Categories

(Core :: Audio/Video: Playback, task, P2)

Unspecified
macOS
task

Tracking

()

RESOLVED FIXED
mozilla71
Tracking Status
firefox71 --- fixed

People

(Reporter: alwu, Assigned: alwu)

References

Details

Attachments

(5 files)

In order to control media directly from the mac's hardware media keys (play/pause, seek, next), we have to intercept those key events from system and do corresponding operations.

In order to receive platform level media hardward keys event, we create a MediaHardwareKeysEventSource which is used to implement intercepting those events according to different platforms.

We can add a MediaHardwareKeysEventListener onto MediaHardwareKeysEventSource, so that we can get notification whenever hardware media keys are being pressed.

MediaHardwareKeysManager is used to encapsulate all these details, it would create a source and corresponding listener.

On OSX, we would use the CG event tap to intercept media keys event.

The ideal situation for media control should be incooperated with the audio competition so that we only have to control one controller.

However, if it's multiple controllers at the same time, we would tend to only control the last one in order to reduce confustion.

Ex. If we pause controller A first, and then start controller B. So what should we do when we press play/pause hardware key?
To resume controller A or to stop controller B, or do both things at the same time?

Pushed by alwu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/239c106912ab
part1 : implement basic classes for handling media hardware keys. r=baku
https://hg.mozilla.org/integration/autoland/rev/a417c89cf52b
part2 : implement the event source on OSX. r=spohl
https://hg.mozilla.org/integration/autoland/rev/deb0bc2ec44f
part3 : implement play/pause controller. r=chunmin
https://hg.mozilla.org/integration/autoland/rev/49618c346430
part4 : add the pref 'media.hardwaremediakeys.enabled' to control this feature. r=baku
https://hg.mozilla.org/integration/autoland/rev/fa579e9b1e7d
part5 : add gTests r=spohl
Regressions: 1594028
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: