-
Notifications
You must be signed in to change notification settings - Fork 767
/
win10.js
69 lines (62 loc) · 2.56 KB
/
win10.js
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
import { MediaPlaybackStatus, MediaPlaybackType, SystemMediaTransportControlsButton } from '@nodert-win10/windows.media';
import { BackgroundMediaPlayer } from '@nodert-win10/windows.media.playback';
import { RandomAccessStreamReference } from '@nodert-win10/windows.storage.streams';
import { Uri } from '@nodert-win10/windows.foundation';
const Controls = BackgroundMediaPlayer.current.systemMediaTransportControls;
Controls.isChannelDownEnabled = false;
Controls.isChannelUpEnabled = false;
Controls.isFastForwardEnabled = false;
Controls.isNextEnabled = true;
Controls.isPauseEnabled = true;
Controls.isPlayEnabled = true;
Controls.isPreviousEnabled = true;
Controls.isRecordEnabled = false;
Controls.isRewindEnabled = false;
Controls.isStopEnabled = true;
if (!Settings.get('enableWin10MediaServiceTrackInfo')) {
Controls.isEnabled = false;
}
Controls.playbackStatus = MediaPlaybackStatus.closed;
Controls.displayUpdater.type = MediaPlaybackType.music;
Controls.displayUpdater.musicProperties.title = 'Google Play Music Desktop Player';
Controls.displayUpdater.musicProperties.artist = TranslationProvider.query('playback-os-no-track-playing');
Controls.displayUpdater.update();
Controls.on('buttonpressed', (sender, eventArgs) => {
switch (eventArgs.button) {
case SystemMediaTransportControlsButton.play:
if (!GPM.playback.isPlaying()) GPM.playback.playPause();
break;
case SystemMediaTransportControlsButton.pause:
if (GPM.playback.isPlaying()) GPM.playback.playPause();
break;
case SystemMediaTransportControlsButton.stop:
if (GPM.playback.isPlaying()) GPM.playback.playPause();
break;
case SystemMediaTransportControlsButton.next:
GPM.playback.forward();
break;
case SystemMediaTransportControlsButton.previous:
GPM.playback.rewind();
break;
default:
break;
}
});
window.wait(() => {
GPM.on('change:playback', (mode) => {
if (mode === 0) {
Controls.playbackStatus = MediaPlaybackStatus.stopped;
} else if (mode === 1) {
Controls.playbackStatus = MediaPlaybackStatus.paused;
} else {
Controls.playbackStatus = MediaPlaybackStatus.playing;
}
});
GPM.on('change:track', (track) => {
Controls.displayUpdater.musicProperties.title = track.title;
Controls.displayUpdater.musicProperties.artist = track.artist;
Controls.displayUpdater.musicProperties.albumTitle = track.album;
Controls.displayUpdater.thumbnail = RandomAccessStreamReference.createFromUri(new Uri(track.albumArt.replace('=s90-c-e100', '')));
Controls.displayUpdater.update();
});
});