Bug 1609452 - part1 : update media center's playback state whenever the event source's playback changes. r=mstange

The event source's playback state can represent if the media is currently playing. Therfore, whenever it changes, we should update the media center's playback state as well in order to show correct controller icon (eg. play and pause) on the touch bar.

Differential Revision: https://phabricator.services.mozilla.com/D60024

--HG--
extra : moz-landing-system : lando
This commit is contained in:
alwu 2020-01-28 09:50:04 +00:00
Родитель 4d3579227c
Коммит 400100469c
2 изменённых файлов: 14 добавлений и 0 удалений

Просмотреть файл

@ -34,6 +34,7 @@ class MediaHardwareKeysEventSourceMacMediaCenter final
virtual bool Open() override;
void Close() override;
virtual bool IsOpened() const override;
void SetPlaybackState(dom::PlaybackState aState) override;
private:
~MediaHardwareKeysEventSourceMacMediaCenter();

Просмотреть файл

@ -150,5 +150,18 @@ void MediaHardwareKeysEventSourceMacMediaCenter::HandleEvent(MediaControlKeysEve
}
}
void MediaHardwareKeysEventSourceMacMediaCenter::SetPlaybackState(PlaybackState aState) {
MPNowPlayingInfoCenter* center =
(MPNowPlayingInfoCenter*)[mpNowPlayingInfoCenterClass defaultCenter];
if (aState == PlaybackState::ePlaying) {
center.playbackState = MPNowPlayingPlaybackStatePlaying;
} else if (aState == PlaybackState::ePaused) {
center.playbackState = MPNowPlayingPlaybackStatePaused;
} else if (aState == PlaybackState::eStopped) {
center.playbackState = MPNowPlayingPlaybackStateStopped;
}
MediaControlKeysEventSource::SetPlaybackState(aState);
}
}
}