Skip to content

Commit

Permalink
fix mpris
Browse files Browse the repository at this point in the history
  • Loading branch information
sneljo1 committed Mar 16, 2019
1 parent e0a5193 commit fc4170b
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 16 deletions.
2 changes: 1 addition & 1 deletion config/build/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ apps:
slots:
auryo-player-mpris:
interface: mpris
name: auryo-player
name: auryo_player
auryo-mpris:
interface: mpris
name: auryo
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,11 @@
"winston": "^3.1.0"
},
"optionalDependencies": {
"@nodert-win10/windows.foundation": "^0.2.95",
"@nodert-win10/windows.media": "^0.2.95",
"@nodert-win10/windows.media.playback": "^0.2.95",
"@nodert-win10/windows.storage.streams": "^0.2.95",
"dbus-next": "0.3.1",
"@nodert-win10/windows.foundation": "^0.2.96",
"@nodert-win10/windows.media": "^0.2.96",
"@nodert-win10/windows.media.playback": "^0.2.96",
"@nodert-win10/windows.storage.streams": "^0.2.96",
"dbus-next": "0.3.2",
"electron-media-service": "^0.2.2",
"mpris-service": "2.0.0"
},
Expand Down
2 changes: 2 additions & 0 deletions src/main/features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Win10MediaService from './win32/win10/win10MediaService';
import Feature from './feature';
import NotificationManager from './core/notificationManager';
import LastFm from './core/lastFm';
import DbusService from './linux/dbusService';

export const tools: Array<typeof Feature> = [
LastFm,
Expand All @@ -34,6 +35,7 @@ export const tools: Array<typeof Feature> = [

// Linux
MprisService,
DbusService
];

export const getTools = (app: Auryo) => tools
Expand Down
5 changes: 3 additions & 2 deletions src/main/features/linux/dbusService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ export default class DbusService extends LinuxFeature {
try {
await this.registerBindings('gnome', session);
} catch (err) {
this.logger.error(err);
// ignore
}

try {
await this.registerBindings('mate', session);
} catch (err) {
this.logger.error(err);
// ignore
}
} catch (e) {
this.logger.error(e);
Expand Down
9 changes: 5 additions & 4 deletions src/main/features/linux/mprisService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { WatchState } from '../feature';
import { MprisServiceClient } from './interfaces/mpris-service.interface';
import LinuxFeature from './linuxFeature';
import { getTrackEntity } from '@common/store/entities/selectors';
import { getCurrentPosition } from '@common/utils';

const logosPath = process.env.NODE_ENV === 'development' ?
path.resolve(__dirname, '..', '..', '..', 'assets', 'img', 'logos') :
Expand All @@ -31,7 +32,7 @@ export default class MprisService extends LinuxFeature {
mpris = require('mpris-service');

this.player = mpris({
name: 'auryo-player',
name: 'auryo_player',
identity: 'Auryo',
canRaise: true,
supportedInterfaces: ['player'],
Expand Down Expand Up @@ -108,7 +109,7 @@ export default class MprisService extends LinuxFeature {
const trackId = playingTrack.id;
const track = getTrackEntity(trackId)(currentState);

const position = queue.indexOf(playingTrack);
const position = getCurrentPosition({ queue, playingTrack });

this.player.canGoPrevious = queue.length > 0 && position > 0;
this.player.canGoNext = queue.length > 0 && position + 1 <= queue.length;
Expand Down Expand Up @@ -179,8 +180,8 @@ export default class MprisService extends LinuxFeature {
...this.player.metadata
};

this.meta['mpris:length'] = duration * 1e3;
this.player.position = currentTime * 1e3;
this.meta['mpris:length'] = duration * 1e3 | 0;
this.player.position = currentTime * 1e3 | 0;

if (!_.isEqual(this.meta, this.player.metadata)) {
this.player.metadata = this.meta;
Expand Down
26 changes: 22 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -638,25 +638,25 @@
classnames "^2.2"
tslib "^1.9.0"

"@nodert-win10/windows.foundation@^0.2.95":
"@nodert-win10/windows.foundation@^0.2.96":
version "0.2.96"
resolved "https://registry.yarnpkg.com/@nodert-win10/windows.foundation/-/windows.foundation-0.2.96.tgz#beb20661d87fb352f9c5c7c45899bf3c24d78cd0"
dependencies:
nan latest

"@nodert-win10/windows.media.playback@^0.2.95":
"@nodert-win10/windows.media.playback@^0.2.96":
version "0.2.96"
resolved "https://registry.yarnpkg.com/@nodert-win10/windows.media.playback/-/windows.media.playback-0.2.96.tgz#017eebc56bb530f9b8f2a456500c3b7d1ce42f35"
dependencies:
nan latest

"@nodert-win10/windows.media@^0.2.95":
"@nodert-win10/windows.media@^0.2.96":
version "0.2.96"
resolved "https://registry.yarnpkg.com/@nodert-win10/windows.media/-/windows.media-0.2.96.tgz#3287830f1c494a53d3d6bbb275f48489204498c5"
dependencies:
nan latest

"@nodert-win10/windows.storage.streams@^0.2.95":
"@nodert-win10/windows.storage.streams@^0.2.96":
version "0.2.96"
resolved "https://registry.yarnpkg.com/@nodert-win10/windows.storage.streams/-/windows.storage.streams-0.2.96.tgz#e2cf392a83c74f918ce4356d905282076a74d13c"
dependencies:
Expand Down Expand Up @@ -3437,6 +3437,20 @@ dbus-next@0.3.1:
optionalDependencies:
abstract-socket "^2.0.0"

dbus-next@0.3.2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/dbus-next/-/dbus-next-0.3.2.tgz#95cbd667ad80b27873a4e6bddd161d44318435e1"
dependencies:
event-stream "3.3.4"
hexy "^0.2.10"
jsbi "^2.0.5"
long "^4.0.0"
put "0.0.6"
safe-buffer "^5.1.1"
xml2js "^0.4.17"
optionalDependencies:
abstract-socket "^2.0.0"

debug@2.6.9, debug@^2.1.2, debug@^2.1.3, debug@^2.2.0, debug@^2.3.3, debug@^2.6.8, debug@^2.6.9:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
Expand Down Expand Up @@ -6664,6 +6678,10 @@ loglevelnext@^1.0.1:
es6-symbol "^3.1.1"
object.assign "^4.1.0"

long@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28"

loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.2.0, loose-envify@^1.3.1, loose-envify@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
Expand Down

0 comments on commit fc4170b

Please sign in to comment.