blob: c2b9d930002e8478f9c95a63397c612913b8d51a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef WIDGET_COCOA_MEDIAHARDWAREKEYSEVENTSOURCEMACMEDIACENTER_H_
#define WIDGET_COCOA_MEDIAHARDWAREKEYSEVENTSOURCEMACMEDIACENTER_H_
#include "mozilla/dom/MediaControlKeySource.h"
#ifdef __OBJC__
@class MPRemoteCommandEvent;
#else
typedef struct objc_object MPRemoteCommandEvent;
#endif
enum MPRemoteCommandHandlerStatus : long;
namespace mozilla {
namespace widget {
typedef MPRemoteCommandHandlerStatus (^MediaCenterEventHandler)(
MPRemoteCommandEvent* event);
class MediaHardwareKeysEventSourceMacMediaCenter final
: public mozilla::dom::MediaControlKeySource {
public:
NS_INLINE_DECL_REFCOUNTING(MediaHardwareKeysEventSourceMacMediaCenter,
override)
MediaHardwareKeysEventSourceMacMediaCenter();
MediaCenterEventHandler CreatePlayPauseHandler();
MediaCenterEventHandler CreateNextTrackHandler();
MediaCenterEventHandler CreatePreviousTrackHandler();
MediaCenterEventHandler CreatePlayHandler();
MediaCenterEventHandler CreatePauseHandler();
bool Open() override;
void Close() override;
bool IsOpened() const override;
void SetPlaybackState(dom::MediaSessionPlaybackState aState) override;
void SetMediaMetadata(const dom::MediaMetadataBase& aMetadata) override;
// Currently we don't support showing supported keys on the touch bar.
void SetSupportedMediaKeys(const MediaKeysArray& aSupportedKeys) override {}
private:
~MediaHardwareKeysEventSourceMacMediaCenter();
void BeginListeningForEvents();
void EndListeningForEvents();
void HandleEvent(dom::MediaControlKey aKey);
bool mOpened = false;
MediaCenterEventHandler mPlayPauseHandler;
MediaCenterEventHandler mNextTrackHandler;
MediaCenterEventHandler mPreviousTrackHandler;
MediaCenterEventHandler mPauseHandler;
MediaCenterEventHandler mPlayHandler;
};
} // namespace widget
} // namespace mozilla
#endif // WIDGET_COCOA_MEDIAHARDWAREKEYSEVENTSOURCEMACMEDIACENTER_H_
|