-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathplayer.js
46 lines (38 loc) · 1.19 KB
/
player.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
var Player = require('../dist');
var player = Player({
name: 'nodejs',
identity: 'Node.js media player',
supportedUriSchemes: ['file'],
supportedMimeTypes: ['audio/mpeg', 'application/ogg'],
supportedInterfaces: ['player']
});
player.getPosition = function() {
// return the position of your player
return 0;
}
// Events
var events = ['raise', 'quit', 'next', 'previous', 'pause', 'playpause', 'stop', 'play', 'seek', 'position', 'open', 'volume', 'loopStatus', 'shuffle'];
events.forEach(function (eventName) {
player.on(eventName, function () {
console.log('Event:', eventName, arguments);
});
});
player.on('quit', function () {
process.exit();
});
setTimeout(function () {
// @see http://www.freedesktop.org/wiki/Specifications/mpris-spec/metadata/
player.metadata = {
'mpris:trackid': player.objectPath('track/0'),
'mpris:length': 60 * 1000 * 1000, // In microseconds
'mpris:artUrl': 'http://www.adele.tv/images/facebook/adele.jpg',
'xesam:title': 'Lolol',
'xesam:album': '21',
'xesam:artist': ['Adele']
};
player.playbackStatus = Player.PLAYBACK_STATUS_PLAYING;
console.log('Now playing: Lolol - Adele - 21');
}, 1000);
setTimeout(() => {
player.seeked(0);
}, 2000);