Closed Bug 1575995 Opened 2 years ago Closed 2 years ago

Use Mac's hardware media keys to control media


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




Tracking Status
firefox71 --- fixed


(Reporter: alwu, Assigned: alwu)




(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
part1 : implement basic classes for handling media hardware keys. r=baku
part2 : implement the event source on OSX. r=spohl
part3 : implement play/pause controller. r=chunmin
part4 : add the pref 'media.hardwaremediakeys.enabled' to control this feature. r=baku
part5 : add gTests r=spohl
Regressions: 1594028
You need to log in before you can comment on or make changes to this bug.