dbusjs / mpris-service Goto Github PK
View Code? Open in Web Editor NEWNode.js implementation for the MPRIS D-Bus Interface Specification to create a mediaplayer service
License: MIT License
Node.js implementation for the MPRIS D-Bus Interface Specification to create a mediaplayer service
License: MIT License
Line 356 in 81665c4
that.interfaces
is not defined (should be this.interfaces
)
Kinda weird that no one catched that before...
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.
I want to "listen" for other players on the system so I can track what songs are being played. Can mpris-service find other players?
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
Now that we have tests, CI would be nice.
dbus-next is merging with dbus-native and forming a new organization under dbusjs
Would you be interested in moving this repo into that organization?
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
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
heya,
i've been trying out google play music desktop player (see also MarshallOfSound/Google-Play-Music-Desktop-Player-UNOFFICIAL-#2321) and found that sending dbus commands manually would always give a timeout response.
is there something mpris-service can or should do to tell callers that things have succeeded instead of just letting it time out?
Tests would be nice to have, but how to implement them?
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.
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.
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',
},
},
};
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):
python layer-mpris-tail.py
in the terminalyarn && 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.
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.
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
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
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?
When setting the value after the initial value is set, the values change but the mpris widget doesn't change anymore.
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?
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
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.
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?
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
If all required features are there, I think it would be nice to switch into pure JS version to improve portability.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.