Code Monkey home page Code Monkey logo

mpris-service's People

Contributors

acrisci avatar emersion avatar jgierer12 avatar jostrander avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mpris-service's Issues

Sending/Receiving negative numbers

I usually use playerctl to control and test my MPRIS applications. I recently switched to the new mpris-service and dbus-next and all the negative values I'm receiving are a bit complement of the actual value.
Here's a simple sample code:

const mpris = require('mpris-service');
const mprisPlayer = mpris({
  name: 'test',
  identity: 'test',
  supportedInterfaces: ['player'],
  desktopEntry: 'test',
});
mprisPlayer.on('seek', (seek) => {
  console.log(`Seek ${seek / 1e6} sec`);
});

Using the following command playerctl position 30- you'll see the following output on the console:

Seek -9223372036824.775 sec

While sending playerctl position 30+ returns the right number.

As a workaround, I've set a complement inside the seek event: if (seek < 0) seek = ~seek;

I think this should have been solved on dbus-next v0.3.2, there's some reference there regarding negative numbers and using Long internally, but this module is using the latest version so I don't know what's going on.

Error while executing `GetAll` on `org.freedesktop.DBus.Properties`

general Information:

- Version: 2.1.2

Issue Description:
When executing the GetAll method to get all properties, an application using mpris-service returns an error:

g-io-error-quark: GDBus.Error:com.github.dbus_next.ServiceError: Service error: The service threw an error.
TypeError: DBusError is not a constructor
    at PlayerInterface.LoopStatus (/opt/YouTube Music/resources/app.asar/node_modules/mpris-service/src/interfaces/player.js:118:13)
    at handleGetAllProperties (/opt/YouTube Music/resources/app.asar/node_modules/dbus-next/lib/service/handlers.js:125:22)
    at handleStdIfaces (/opt/YouTube Music/resources/app.asar/node_modules/dbus-next/lib/service/handlers.js:240:7)
    at handleMessage (/opt/YouTube Music/resources/app.asar/node_modules/dbus-next/lib/service/handlers.js:280:7)
    at handleMessage (/opt/YouTube Music/resources/app.asar/node_modules/dbus-next/lib/bus.js:136:21)
    at EventEmitter.<anonymous> (/opt/YouTube Music/resources/app.asar/node_modules/dbus-next/lib/bus.js:151:9)
    at EventEmitter.emit (node:events:527:28)
    at /opt/YouTube Music/resources/app.asar/node_modules/dbus-next/lib/connection.js:116:14
    at Socket.<anonymous> (/opt/YouTube Music/resources/app.asar/node_modules/dbus-next/lib/message.js:63:9)
    at Socket.emit (node:events:527:28) (36)

More Information:
More information is found in this issue in the application's repo

Add CI

Now that we have tests, CI would be nice.

mpris-service 2.0 fails because of JSBI.BigInt with Webpack

on Electron 4.0.6 (Node 10.11), I have the following error when using [email protected]:

A JavaScript error occurred in the main process
Uncaught Exception:
TypeError: JSBI.BigInt is not a function
    at Object../node_modules/dbus-next/lib/marshallers.js (/home/pierre/Documents/museeks/dist/main/webpack:/node_modules/dbus-next/lib/marshallers.js:267:1)
    at __webpack_require__ (/home/pierre/Documents/museeks/dist/main/webpack:/webpack/bootstrap:19:1)
    at Object../node_modules/dbus-next/lib/marshall.js (/home/pierre/Documents/museeks/dist/main/webpack:/node_modules/dbus-next/lib/marshall.js:5:21)
    at __webpack_require__ (/home/pierre/Documents/museeks/dist/main/webpack:/webpack/bootstrap:19:1)
    at Object../node_modules/dbus-next/lib/message.js (/home/pierre/Documents/museeks/dist/main/webpack:/node_modules/dbus-next/lib/message.js:2:18)
    at __webpack_require__ (/home/pierre/Documents/museeks/dist/main/webpack:/webpack/bootstrap:19:1)
    at Object../node_modules/dbus-next/index.js (/home/pierre/Documents/museeks/dist/main/webpack:/node_modules/dbus-next/index.js:7:17)
    at __webpack_require__ (/home/pierre/Documents/museeks/dist/main/webpack:/webpack/bootstrap:19:1)
    at Object../node_modules/mpris-service/dist/index.js (/home/pierre/Documents/museeks/dist/main/webpack:/node_modules/mpris-service/dist/index.js:7:14)
    at __webpack_require__ (/home/pierre/Documents/museeks/dist/main/webpack:/webpack/bootstrap:19:1)

Most probably caused by @acrisci's node-dbus-next. I am not sure what could cause this as this version of node support BigInt.

This is reproducible like that:

git clone https://github.com/martpie/museeks.git
cd museeks
git checkout mpris-service-2
npm install
npm run modules:rebuild
npm run build # npm run dev to watch
npm run museeks:debug

No longer works with node-dbus 0.2.14

will just throw an undefined symbol error.

node: symbol lookup error: /home/jake/dev/mpris-service/node_modules/dbus/build/Release/dbus.node: undefined symbol: _ZN6Signal14DispatchSignalEPN2v86HandleINS0_5ValueEEE

Add tests

Tests would be nice to have, but how to implement them?

DBus connection error handling

Errors with the underlying connection to DBus may happen asynchonously. Establishing the connection and exporting the name on the bus is async and may fail after the constructor returns the player.

  • connection to dbus cannot be established
  • the name cannot be exported
  • dbus connection is closed after connection is established

Error handling should be for debug logging to explain what happened and also give the user an option to retry the connection.

Best solution is probably to have an error event on the player with the original error and a message of what went wrong.

player.on('error', (err, message) => { /* handle error */ })

Maybe give a hint to whether the player is connected after the error with a player property.

We can proxy the dbus-next connection error events into this when they happen.

TypeError: JSBI.BigInt is not a function

I've seen a few of these errors in the issues, and I've applied the fix from #23 and it seems to be mapped properly, but it still has the same error as before.

WARNING  Compiled with 1 warnings                                                                                                                                                                      12:07:17 AM
                                                                                                                                                                                                                   
 warning  in ./node_modules/dbus-next/lib/address-x11.js                                                                                                                                                           
                                                                                                                                                                                                                   
Module not found: Error: Can't resolve 'x11' in '/home/joe/Development/my_project/node_modules/dbus-next/lib'                                                                                                        
                                                                                                                                                                                                                   
  File                      Size                     Gzipped                                                                                                                                                       
                                                                                                                                                                                                                   
  dist_electron/index.js    1371.53 KiB              283.94 KiB                                                                                                                                                    
                                                                                                                                                                                                                   
  Images and other types of assets omitted.                                                                                                                                                                        
                                                                                                                                                                                                                   
                                                                                                                                                                                                                   
                                                                                                                                                                                                                   
 DONE  Compiled successfully in 10ms                                                                                                                                                                    12:07:17 AM
                                                                                                                                                                                                                   
  File                        Size                    Gzipped                                                                                                                                                      
                                                                                                                                                                                                                   
  dist_electron/preload.js    4.86 KiB                1.35 KiB                                                                                                                                                     
                                                                                                                                                                                                                   
  Images and other types of assets omitted.                                                                                                                                                                        
                                                                                                                                                                                                                   
 INFO  Launching Electron...                                                                                                                                                                                       
App threw an error during load                                                                                                                                                                                     
TypeError: JSBI.BigInt is not a function                                                                                                                                                                           
    at eval (webpack:///./node_modules/dbus-next/lib/marshallers.js?:255:24)                                                                                                                                       
    at Object../node_modules/dbus-next/lib/marshallers.js (/home/joe/Development/my_project/dist_electron/index.js:329:1)                                                                                            
    at __webpack_require__ (/home/joe/Development/my_project/dist_electron/index.js:20:30)                                                                                                                           
    at eval (webpack:///./node_modules/dbus-next/lib/marshall.js?:5:21)                                                                                                                                            
    at Object../node_modules/dbus-next/lib/marshall.js (/home/joe/Development/my_project/dist_electron/index.js:318:1)                                                                                               
    at __webpack_require__ (/home/joe/Development/my_project/dist_electron/index.js:20:30)                                                                                                                           
    at eval (webpack:///./node_modules/dbus-next/lib/message.js?:2:18)                                                                                                                                             
    at Object../node_modules/dbus-next/lib/message.js (/home/joe/Development/my_project/dist_electron/index.js:340:1)                                                                                                
    at __webpack_require__ (/home/joe/Development/my_project/dist_electron/index.js:20:30)                                                                                                                           
    at eval (webpack:///./node_modules/dbus-next/lib/connection.js?:3:17)                                                                                                                                          
A JavaScript error occurred in the main process                                                                                                                                                                    
Uncaught Exception:                                                                                                                                                                                                
TypeError: JSBI.BigInt is not a function                                                                                                                                                                           
    at eval (webpack:///./node_modules/dbus-next/lib/marshallers.js?:255:24)                                                                                                                                       
    at Object../node_modules/dbus-next/lib/marshallers.js (/home/joe/Development/my_project/dist_electron/index.js:329:1)                                                                                            
    at __webpack_require__ (/home/joe/Development/my_project/dist_electron/index.js:20:30)                                                                                                                           
    at eval (webpack:///./node_modules/dbus-next/lib/marshall.js?:5:21)                                                                                                                                            
    at Object../node_modules/dbus-next/lib/marshall.js (/home/joe/Development/my_project/dist_electron/index.js:318:1)                                                                                               
    at __webpack_require__ (/home/joe/Development/my_project/dist_electron/index.js:20:30)                                                                                                                           
    at eval (webpack:///./node_modules/dbus-next/lib/message.js?:2:18)                                                                                                                                             
    at Object../node_modules/dbus-next/lib/message.js (/home/joe/Development/my_project/dist_electron/index.js:340:1)                                                                                                
    at __webpack_require__ (/home/joe/Development/my_project/dist_electron/index.js:20:30)                                                                                                                           
    at eval (webpack:///./node_modules/dbus-next/lib/connection.js?:3:17)

Here's how I have webpack setting the alias (in vue.config.js):

const path = require('path');

module.exports = {
  chainWebpack: config => {
    config.resolve.alias.set('jsbi', path.resolve('node_modules/jsbi/dist/jsbi-cjs.js'));
  },
  pluginOptions: {
    electronBuilder: {
      preload: 'src/preload.js',
    },
  },
};

Got error when detecting the player status using other scripts

I'm using a script called player-mpris-tail for the polybar to show player status.
It works fine with players with mpris support. It also works with mpris-service module if it's standalone. However, I got error from the script when test mpris-service with electron.

Here's a minimal reproduce example

These steps may reproduce the problem (there's a probability):

  1. Run python layer-mpris-tail.py in the terminal
  2. Open another terminal. Run yarn && yarn start

It may take several times to reproduce it.

And you will got the following error in the first terminal:

ERROR:dbus.connection:Exception in handler for D-Bus signal:
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/dbus/connection.py", line 230, in maybe_handle_message
    self._handler(*args, **kwargs)
  File "player-mpris-tail.py", line 48, in onOwnerChangedName
    self.addPlayer(bus_name, new_owner)
  File "player-mpris-tail.py", line 66, in addPlayer
    player = Player(self._session_bus, bus_name, owner = owner, connect = self._connect, _print = self.print)
  File "player-mpris-tail.py", line 162, in __init__
    self.connect()
  File "player-mpris-tail.py", line 181, in connect
    introspect_xml = self._introspect(self.bus_name, '/')
  File "/usr/lib/python3.7/site-packages/dbus/proxies.py", line 70, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib/python3.7/site-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib/python3.7/site-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method 'Introspect' on interface 'org.freedesktop.DBus.Introspectable' does not exist
ERROR:dbus.connection:Exception in handler for D-Bus signal:
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/dbus/connection.py", line 230, in maybe_handle_message
    self._handler(*args, **kwargs)
  File "player-mpris-tail.py", line 50, in onOwnerChangedName
    self.removePlayer(old_owner)
  File "player-mpris-tail.py", line 70, in removePlayer
    self.players[owner].disconnect()
KeyError: dbus.String(':1.158')

I have been disturbed by the problem for long.
I create a plain nodejs script using mpris-service and a project using electron and mpris-service ( as provide above ) .
Then I used dbus-monitor and compared their output.( Their output are also contained in the above project ).It seemed that the one with electron missed something.

Changing property results in EPIPE errors

What am I doing wrong? I play around with player.js example, with the addition of error handler so I can see errors in console.
I'm doing this in an electron app if that makes a difference.

I create Player object and get MPRIS notification for unknown track.
I try to change metadata or playbackStatus and it immediately throws EPIPE or write stream after closed errors.
If I don't change properties everything works, but it's kinda useless like that.

Support multiple instances

According to the MPRIS bus name policy.

In the case where the media player allows multiple instances running simultaneously, each additional instance should request a unique bus name, adding a dot and a unique identifier to its usual bus name, such as one based on a UNIX process id. For example, this could be:
org.mpris.MediaPlayer2.vlc.instance7389

Wrong types for some properties

Using the latest version,

(playerctl:16525): GLib-GIO-WARNING **: Received property Rate with type y does not match expected type d in the expected interface

(playerctl:16525): GLib-GIO-WARNING **: Received property Volume with type y does not match expected type d in the expected interface

(playerctl:16525): GLib-GIO-WARNING **: Received property Position with type y does not match expected type x in the expected interface

(playerctl:16525): GLib-GIO-WARNING **: Received property MinimumRate with type y does not match expected type d in the expected interface

(playerctl:16525): GLib-GIO-WARNING **: Received property MaximumRate with type y does not match expected type d in the expected interface

Error: The module was compiled against a different Node.js version using NODE_MODULE_VERSION 48.

Hi, I'm getting the following error after trying to use mpris-service and running my program:

Error: The module '<project>/node_modules/dbus/build/Release/dbus.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. This version of Node.js requires
NODE_MODULE_VERSION 54. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or`npm install`).
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
    at Object.Module._extensions..node (module.js:598:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (<project>/node_modules/dbus/lib/dbus.js:3:13)
    at Object.<anonymous> (<project>/node_modules/dbus/lib/dbus.js:148:3)

I'm trying to use it in an Electron program. Would you happen to know how to recompile dbus.node to work with my version of node (6.10.1)? Or maybe there's a different fix for this issue?

TypeError: JSBI.BigInt is not a function

Node version: 12.0.0
Electron version: 5.0.6
Chrome version: 73.0.3683.121

I'm trying to add mpris support for a existing music player rapiz1/petal.
The project uses Webpack and react-scripts, which I have little knowledge of. Maybe it's caused by Webpack?

Media Keys stop working after closing window

Hello there!
I'm working on a little desktop Youtube Music App. It uses this library to provide the Metadata and controls on Gnome. When running the app for the first time it works perfectly, but if I close the app window and restart it, the keyboard media keys do not work any more (The notification and the controls there by clicking still work).

By some reason, if I instead close the app by Ctrl+C on the terminal and then open it again, the media keys keep working the next time I open the app.

The only way I found to get the media keys working again once "they are lost" is by closing the session and re-login.

OS: Fedora 30 Workstation
Gnome Version: 3.32.2
Node: 12.9.0
Electron: 6.0.3

use latest dbus-next

This module is using an outdated version of dbus-next which contains some vulnerabilities as shown by running npm audit. The vulnerabilities have been fixed on newer versions of dbus-next. Hopefully, a simple version bump is needed and there aren't any breaking changes between releases that could delay this.

Documentation hosting

I'm not really sure the best way to do this. There is no equivalent of something like read-the-docs for jsdoc projects.

Github Pages will work well for this but I don't like the idea of putting compiled documentation in this repository.

On dbus-next, I've decided to use a separate doc repository that will be shared for my projects which contains the project documentation:

https://github.com/acrisci/doc

Which is then hosted here:

https://acrisci.github.io/doc/node-dbus-next/

But there is a manual update step when the project releases.

How do you think we should do this?

Volume can't be set by MPRIS control.

I've used the player.js example and added a initial volume at line 22 "player.volume = 0.5;".

My shell extension (Media player indicator) shows the volume, but if i change it the service crashes:

/opt/test/node_modules/mpris-service/index.js:281
            next();
            ^
TypeError: undefined is not a function
    at iface.addProperty.setter (/opt/test/node_modules/mpris-service/index.js:281:4)
    at ServiceInterface.setProperty (/opt/test/node_modules/mpris-service/node_modules/dbus/lib/service_interface.js:142:14)
    at null.<anonymous> (/opt/test/node_modules/mpris-service/node_modules/dbus/lib/service_object.js:55:14)
    at ServiceInterface.call (/opt/test/node_modules/mpris-service/node_modules/dbus/lib/service_interface.js:108:17)
    at null.<anonymous> (/opt/test/node_modules/mpris-service/node_modules/dbus/lib/service.js:19:14)
    at emit (events.js:118:17)
    at /opt/test/node_modules/mpris-service/node_modules/dbus/lib/dbus.js:25:16

I think there is a bug in "node-dbus" as well which i've fixed: Shouqun/node-dbus#102

Use pure JS node-dbus ?

If all required features are there, I think it would be nice to switch into pure JS version to improve portability.

Metadata don't work

I'm using this module and it works, it show player controls in https://github.com/azdyb/gnome-shell-extension-mpriscontrol and events are working but i can't send any metadata. I tried to update to node-dbus to 1.0.0 version following this https://github.com/Shouqun/node-dbus/blob/master/MIGRATING.md but it still failing.

How can i do for solve this?

This isn't problem of gnome shell because it works with other players. I tried in ubuntu 16.04 and ubuntu gnome 16.04 and linux mint without any successful result.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.