11function createPlayer ( webContents , window ) {
22 // eslint-disable-next-line global-require
3- const Player = require ( 'mpris-service' )
3+ const MprisService = require ( 'mpris-service' )
44
5- const player = Player ( {
5+ const mprisService = MprisService ( {
66 name : 'YandexMusic' ,
77 identity : 'YandexMusic media player' ,
88 supportedUriSchemes : [ 'file' ] ,
@@ -11,37 +11,37 @@ function createPlayer(webContents, window) {
1111 } )
1212
1313 // Events
14- player . on ( 'play' , ( ) => {
14+ mprisService . on ( 'play' , ( ) => {
1515 webContents . send ( 'player:play' )
1616 } )
1717
18- player . on ( 'pause' , ( ) => {
18+ mprisService . on ( 'pause' , ( ) => {
1919 webContents . send ( 'player:pause' )
2020 } )
2121
22- player . on ( 'playpause' , ( ) => {
22+ mprisService . on ( 'playpause' , ( ) => {
2323 webContents . send ( 'player:playPause' )
2424 } )
2525
26- player . on ( 'next' , ( ) => {
26+ mprisService . on ( 'next' , ( ) => {
2727 webContents . send ( 'player:next' )
2828 } )
2929
30- player . on ( 'previous' , ( ) => {
30+ mprisService . on ( 'previous' , ( ) => {
3131 webContents . send ( 'player:prev' )
3232 } )
33- player . on ( 'position' , ( data ) => {
33+ mprisService . on ( 'position' , ( data ) => {
3434 webContents . send ( 'player:setPosition' , data . position )
3535 } )
3636
37- player . on ( 'quit' , ( ) => {
37+ mprisService . on ( 'quit' , ( ) => {
3838 process . exit ( )
3939 } )
4040
4141 // Metadata
4242
4343 // return the position of your player
44- player . getPosition = ( ) => 0
44+ mprisService . getPosition = ( ) => 0
4545
4646 // eslint-disable-next-line global-require
4747 const ipc = require ( 'electron' ) . ipcMain
@@ -50,16 +50,16 @@ function createPlayer(webContents, window) {
5050 const { trackId, title, artists, playbackStatus, length, seek, artUrl, album } = metadata
5151 window . setTitle ( `${ artists } - ${ title } ` )
5252 // @see http://www.freedesktop.org/wiki/Specifications/mpris-spec/metadata/
53- player . metadata = {
54- 'mpris:trackid' : player . objectPath ( trackId ) ,
53+ mprisService . metadata = {
54+ 'mpris:trackid' : mprisService . objectPath ( trackId ) ,
5555 'mpris:length' : length ,
5656 'mpris:artUrl' : artUrl ,
5757 'xesam:title' : title ,
5858 'xesam:album' : album ,
5959 'xesam:artist' : artists
6060 }
61- player . playbackStatus = playbackStatus
62- player . seeked ( seek )
61+ mprisService . playbackStatus = playbackStatus
62+ mprisService . seeked ( seek )
6363 webContents . send ( 'player:metadata' , metadata )
6464 } )
6565}
0 commit comments