-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmedia.ts
79 lines (71 loc) · 1.92 KB
/
media.ts
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Special Keys
class MediaKey {
static readonly next = 0x01
static readonly previous = 0x02
static readonly stop = 0x04
static readonly eject = 0x08
static readonly playPause = 0x10
static readonly mute = 0x20
static readonly vol_up = 0x40
static readonly vol_down = 0x80
}
//% color=#ff00FF
//% icon="\uf04b"
//% block="Media"
namespace media {
//% blockId="media service" block="bluetooth media service"
//% shim=media::startMediaService
//% weight=50
export function startMediaService() : void {
return
}
//% blockId="send code" block="send code | $code"
//% code.shadow="mediakey_conv"
//% shim=media::sendCode
//% weight=40
export function sendCode(code: number) : void {
return
}
//% blockID="media on status change" block="on media status change" advanced=true
//% shim=media::setStatusChangeHandler
//% weight=20
export function setStatusChangeHandler(a: Action) {
return
}
//% blockId="media enabled" block="media enabled" advanced=true
//% shim=media::isEnabled
//% weight=10
export function isEnabled() : boolean {
return false;
}
export enum _MediaKey {
next,
previous,
stop,
eject,
//% block="play/pause"
playPause,
mute,
//% block="volume up"
vol_up,
//% block="volume down"
vol_down,
}
//% blockId="mediakey_conv" block="%key"
//% weight=20
export function keys(key : _MediaKey) : number {
let keys = [
MediaKey.next,
MediaKey.previous,
MediaKey.stop,
MediaKey.eject,
MediaKey.playPause,
MediaKey.mute,
MediaKey.vol_up,
MediaKey.vol_down
]
if(key>=_MediaKey.next && key<=_MediaKey.vol_down)
return keys[key];
return 0;
}
}