Giter Club home page Giter Club logo

Comments (2)

acrisci avatar acrisci commented on June 25, 2024

This is going to be a bit difficult because a media player exposes the interface on the session bus and there can be zero or many session buses running on your system. The library will read DBUS_SESSION_BUS_ADDRESS env variable to specify which one (which is usually set by a session manager). You might want to look into using a dbus-activatable service which I use for playerctld on the Playerctl project.

from node-dbus-next.

namxam avatar namxam commented on June 25, 2024

@acrisci Thank you. I was already researching in this direction and it seems that I have a working setup… or at least a partially working solution.

I guess there might be more people who might be interested in this solution, so I try to be as explicit as possible.

I created a dbus service

# /usr/share/dbus-1/services/org.mpris.MediaPlayer2.vlc.service
[D-BUS Service]
Name=org.mpris.MediaPlayer2.vlc
Exec=/bin/false
SystemdService=vlc.service

with a corresponding systemd service

# /etc/systemd/user/vlc.service
Description=VLC media player

[Service]
Type=dbus
BusName=org.mpris.MediaPlayer2.vlc
Environment="DISPLAY=:0"
ExecStart=/usr/bin/vlc --video-on-top --fullscreen --no-video-title-show --no-osd --no-spu --start-paused

When I send a dbus message from command line it all works as expected and vlc is launched.
Next I created a systemd user service for my application

[Unit]
Description=Demo MediaPlayer
After=dbus.service

[Service]
ExecStart=/usr/bin/node demo.mjs
WorkingDirectory=/home/pi/demo-media-player
StandardOutput=inherit
StandardError=inherit
Restart=always
Environment="DISPLAY=:0"

[Install]
WantedBy=default.target

I made sure that user services get loaded during boot via loginctl enable-linger $USER. And when I enable it and reboot, the app starts as expected. BUT for some reason, it now hangs indefinitely when getting the proxy object. In my code this line hangs

let dbus = await bus.getProxyObject(
    "org.mpris.MediaPlayer2.vlc",
    "/org/mpris/MediaPlayer2"
  );

When I restart the service via systemctl --user restart demo.service it works immediately. It just hangs after rebooting the system. I also checked and the VLC service is running as expected.

Any idea what might cause it?

from node-dbus-next.

Related Issues (20)

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.