decorators are bad
This commit is contained in:
parent
a3ca0b09f4
commit
6b663e3eb2
1 changed files with 6 additions and 18 deletions
|
@ -31,19 +31,6 @@ export default class mpris {
|
||||||
console.debug(`[Plugin][${mpris.name}] Loading Complete.`);
|
console.debug(`[Plugin][${mpris.name}] Loading Complete.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Blocks non-linux systems from running this plugin
|
|
||||||
* @private
|
|
||||||
* @decorator
|
|
||||||
*/
|
|
||||||
private static linuxOnly(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
|
|
||||||
if (process.platform !== "linux") {
|
|
||||||
descriptor.value = function () {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects to MPRIS Service
|
* Connects to MPRIS Service
|
||||||
*/
|
*/
|
||||||
|
@ -102,6 +89,7 @@ export default class mpris {
|
||||||
* Update M.P.R.I.S Player Attributes
|
* Update M.P.R.I.S Player Attributes
|
||||||
*/
|
*/
|
||||||
private static updateMetaData(attributes: any) {
|
private static updateMetaData(attributes: any) {
|
||||||
|
console.log(attributes)
|
||||||
mpris.player.metadata = {
|
mpris.player.metadata = {
|
||||||
"mpris:trackid": mpris.player.objectPath(`track/${attributes.playParams.id.replace(/[.]+/g, "")}`),
|
"mpris:trackid": mpris.player.objectPath(`track/${attributes.playParams.id.replace(/[.]+/g, "")}`),
|
||||||
"mpris:length": attributes.durationInMillis * 1000, // In microseconds
|
"mpris:length": attributes.durationInMillis * 1000, // In microseconds
|
||||||
|
@ -134,24 +122,24 @@ export default class mpris {
|
||||||
/**
|
/**
|
||||||
* Runs on app ready
|
* Runs on app ready
|
||||||
*/
|
*/
|
||||||
@mpris.linuxOnly
|
|
||||||
onReady(_: any): void {
|
onReady(_: any): void {
|
||||||
|
if (process.platform !== "linux") return;
|
||||||
console.debug(`[${mpris.name}:onReady] Ready.`);
|
console.debug(`[${mpris.name}:onReady] Ready.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renderer ready
|
* Renderer ready
|
||||||
*/
|
*/
|
||||||
@mpris.linuxOnly
|
|
||||||
onRendererReady(): void {
|
onRendererReady(): void {
|
||||||
|
if (process.platform !== "linux") return;
|
||||||
mpris.connect();
|
mpris.connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs on app stop
|
* Runs on app stop
|
||||||
*/
|
*/
|
||||||
@mpris.linuxOnly
|
|
||||||
onBeforeQuit(): void {
|
onBeforeQuit(): void {
|
||||||
|
if (process.platform !== "linux") return;
|
||||||
console.debug(`[Plugin][${mpris.name}] Stopped.`);
|
console.debug(`[Plugin][${mpris.name}] Stopped.`);
|
||||||
mpris.clearState();
|
mpris.clearState();
|
||||||
}
|
}
|
||||||
|
@ -160,8 +148,8 @@ export default class mpris {
|
||||||
* Runs on playback State Change
|
* Runs on playback State Change
|
||||||
* @param attributes Music Attributes (attributes.status = current state)
|
* @param attributes Music Attributes (attributes.status = current state)
|
||||||
*/
|
*/
|
||||||
@mpris.linuxOnly
|
|
||||||
onPlaybackStateDidChange(attributes: any): void {
|
onPlaybackStateDidChange(attributes: any): void {
|
||||||
|
if (process.platform !== "linux") return;
|
||||||
mpris.player.playbackStatus = attributes?.status ? Player.PLAYBACK_STATUS_PLAYING : Player.PLAYBACK_STATUS_PAUSED;
|
mpris.player.playbackStatus = attributes?.status ? Player.PLAYBACK_STATUS_PLAYING : Player.PLAYBACK_STATUS_PAUSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,8 +157,8 @@ export default class mpris {
|
||||||
* Runs on song change
|
* Runs on song change
|
||||||
* @param attributes Music Attributes
|
* @param attributes Music Attributes
|
||||||
*/
|
*/
|
||||||
@mpris.linuxOnly
|
|
||||||
onNowPlayingItemDidChange(attributes: object): void {
|
onNowPlayingItemDidChange(attributes: object): void {
|
||||||
|
if (process.platform !== "linux") return;
|
||||||
mpris.updateMetaData(attributes);
|
mpris.updateMetaData(attributes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue