-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest.js
47 lines (42 loc) · 1.11 KB
/
test.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
const winPlayer = require(".");
async function main() {
const playerManager = await winPlayer.getPlayerManager();
let player;
async function pmEventPolling() {
while (evt = await playerManager.pollNextEvent()) {
console.log("manager event", evt);
switch (evt) {
case "SystemSessionChanged":
playerManager.updateSystemSession();
break;
case "ActiveSessionChanged":
player = await playerManager.getActiveSession();
if (!player)
console.log("manager: WTF?!");
else {
console.log("player attached:", await player?.getAumid());
eventPolling();
}
break;
case "SessionsChanged":
playerManager.updateSessions(null);
break;
}
}
}
async function eventPolling() {
while (evt = await player?.pollNextEvent()) {
console.log("player event", evt);
switch (evt) {
case "PlaybackInfoChanged":
console.log("status", await player?.getStatus())
break;
case "TimelinePropertiesChanged":
console.log("status and pos", await player?.getStatus(), await player?.getPosition(false))
break;
}
}
}
pmEventPolling()
}
main();