Open ilya-zlobintsev opened 3 years ago
It's definitely possible but this is possibility a very substantial addition. There is an input manager for handling remote control of other types (not sure about mpris) that I haven't done anything with yet.
There's an mpris plugin for mpv, but I don't know if it works with libmpv (which is used here if I understand it correctly?) without the full player.
It does work in MPV Shim but this player doesn't respond to MPV keybinds or player events. It is more treated like an embedded player.
I've made this small script to play/pause:
import requests
import os
from os.path import expanduser
home = expanduser("~")
TOKEN = "1234567890abcdefgh"
SERVER_URL = "https://jellyfin.example.com"
headers = {
"X-Emby-Authorization": """MediaBrowser Client="Python", Device="script", DeviceId="asdf", Version="0.1", Token=\"""" + TOKEN + "\"" }
try:
f = open(home + "/.cache/jellyfin-id")
session_id = f.read()
except:
sessions = requests.get(SERVER_URL + "/Sessions?ActiveWithinSeconds=960", headers=headers).json()
for session in sessions:
if session["DeviceName"] == "Web Browser":
session_id = session["Id"]
f = open(home + "/.cache/jellyfin-id", "w")
f.write(session_id)
break
requests.post(SERVER_URL + "/Sessions/" + session_id + "/Playing/PlayPause", headers=headers)
If you install this and softlink mpris.so
to /usr/share/mpv/scripts/mpris.so
in ~/.local/share/jellyfinmediaplayer/scripts
, play/pause and metadata works perfectly, both for music and video.
Thank you, that works perfectly, though the path was /usr/lib/mpv/mpris.so
for me.
Would it be possible to include the plugin by default with it being MIT licensed?
Is it possible to add play/pause with spacebar key? (Windows 10)
There is partial media key support on Linux in the new release. It just binds to the keyboard keys and doesn't do any MPRIS stuff. This may or may not work in Flatpak.
For MPRIS it looks like combining https://packages.debian.org/buster/libmpris-qt5-1 and the taskbar component added recently is a solid option.
Linking/copying mpris.so to the Jellyfin media player scripts directory worked for me. The only slight annoyance is that title information is not shown. The mpris notification only shows the streaming URL that is being used.
Linking the mpris.so file indeed works, here's a handy command to link the file:
ln -s /usr/lib/mpv/mpris.so ~/.local/share/jellyfinmediaplayer/scripts
It has full MPRIS support, except for the information. Has anyone found a fix for that yet?
@zjeffer I started on a fix for missing title data but as I talked to the other developers, I realised there are other issues with this hacky solution to MPRIS.
The problem is that since this is being applied from the MPV side, the next/previous track buttons don't work, because MPV doesn't know what the next/previous items are. MPRIS needs to be implemented at a deeper level in JMP.
That said, if you just want play/pause functionality, then just copy/link the mpris.so file and you're good for now.
I noticed some files do correctly display metadata, but I haven't figured out what causes it.
I haven't seen that at all. Anything I play with MPRIS enabled just shows the streaming URL that mpv is using behind the scenes.
I noticed some files do correctly display metadata, but I haven't figured out what causes it.
This is likely due to embedded metadata that MPV is reading from the files and not any metadata in Jellyfin.
This is likely due to embedded metadata that MPV is reading from the files and not any metadata in Jellyfin.
Makes sense, that's probably it.
Like viggy96 said, prev/next don't work, and neither does stop. prev/next not working is OK but pressing stop seems to cut the connection between jellyfin media player and mpris so and subsequent media key presses don't work until I press stop in jellyfin media player and then start media again. Any updates on this? I'm using a Corsair K70 keyboard
I'm on Ubuntu 20.04 and with latest JMP (v 1.6.1) media keys do not work at all. I tried both, Flatpak and deb version. Is there anything additional software I need to get it working?
@v1r0x Did you try this? https://github.com/jellyfin/jellyfin-media-player/issues/3#issuecomment-841690432
You might need to change the mpris.so path, I don't know where it is on Ubuntu.
@zjeffer I downloaded the mpris.so from this repo: https://github.com/hoyon/mpv-mpris and moved it to the JMP scripts folder, but after a restart it still doesn't work
@zjeffer I downloaded the mpris.so from this repo: https://github.com/hoyon/mpv-mpris and moved it to the JMP scripts folder, but after a restart it still doesn't work
What I had to do was install mpv-mpris, in my case via the AUR on arch Linux, and then symlink the .so for the mpv-mpris into the scripts folder. This process is described above in this thread
The shared library (.so) won't do anything without the mpv-mpris package being installed correctly
I finally have fixed it :tada: Thanks @zjeffer and @mueslimak3r !
I couldn't find a way to install mpv-mpris on ubuntu, but I found a PPA to install mpv itself and copy the prebuild mpris.so
from hoyons repo to JMP scripts folder.
Now Play/Pause works fine :)
There's actually a standard API for responding to media key events (which doesn't include hacky workarounds such as subscribing to individual Xf86* media keys): the Navigator Media Session API. It looks like Jellyfin Web already subscribes to events from this API: https://github.com/jellyfin/jellyfin-web/blob/5c09077a2f12ae44e7b7d356ea8d9f35862b0b60/src/components/playback/mediasession.js#L215
From my limited understanding of Qt, could this be an upstream issue with QtWebEngine? If it does not already do so, shouldn't it provide this API to embedded websites?
Qt can't easily just make this work as is, because the video player isn't part of Qt itself. If Qt does support that then it's theoretically possible to write something that works between MPV and Qt's javascript APIs to then use that Navigator Media Session API, but it would likely be just as easy as writing the mpris support directly into JMP itself. (although perhaps more platform-independant)
Was anyone able to replicate any of these solution within the flatpak? I have attempted the linking with no success.
ln -s ~/.var/app/io.mpv.Mpv/config/mpv/scripts/mpris.so ~/.var/app/com.github.iwalton3.jellyfin-media-player/data/jellyfinmediaplayer/scripts
Does the aformentioned mpris.so solution still work? I tried installing mpv-mpris and symlinking as suggested but jmp doesn't seem to be doing anything with it. I tried loading it with mpv itself to check if the so might be corrupted but it worked fine there. Anyone know what I could be doing wrong?
sudo pacman -S mpv-mpris
ln -sv /usr/lib/mpv-mpris/mpris.so ~/.local/share/jellyfinmediaplayer/scripts/
I'm on jellyfinmediaplayer 1.7.1
.
Edit: Nevermind. Working as expected now (not sure what changed :thinking:).
I tried bundling this into flatpak and got stuck with the following.
config-dir
to a custom one. Thus ignoring all other config directoriesmpris.so
during the buildNothing that can be done unless the above config-dir
setting is not set
Was anyone able to replicate any of these solution within the flatpak? I have attempted the linking with no success.
ln -s ~/.var/app/io.mpv.Mpv/config/mpv/scripts/mpris.so ~/.var/app/com.github.iwalton3.jellyfin-media-player/data/jellyfinmediaplayer/scripts
Still works for me
This really needs a proper solution as it is impeding use of this for HTPC. As it stands without this, the best option currently is to use Firefox in kiosk mode.
The mpris.so solution works for me (archlinux) but only for the pause / play command (which is better than nothing). Could do with the next / prev commands working, too.
I am running EndeavourOS with kde. I have installed mpv-mpris and linked the file mpris.so from /usr/lib/mpv-mpris to ~/.local/share/jellyfinmediaplayer/scripts
After restarting jellyfin and the media center still doesn't detect that I'm playing media (which is annoying because that is the fix on kde to not suspend the machine or turn off the screen after the specified period).
Is there a different fix for it?
I tried going to firefox. Firefox only supports 720p on jellyfin (I have the playback limit to 10mbps on the host but the client app still shows higher qualities though) which is a shame as I am not able to watch the content I want on their resolution.
After looking a bit through jellyfinmediaplayer.log
, I noticed that it does find the script in the Flatpak version, but it fails to load it:
2024-02-07 22:56:19.292 [critical] unknown @ 0 - mpris: C plugin error: 'libavformat.so.58: cannot open shared object file: No such file or directory'
2024-02-07 22:56:19.292 [critical] unknown @ 0 - mpris: Could not load cplugin script /home/username/.var/app/com.github.iwalton3.jellyfin-media-player/data/jellyfinmediaplayer/scripts/mpris.so
It appears that in the last update of mpv-mpris (version 1.1), an extra dependency was added for libavformat.so
and even though I have libavformat.so.60
installed, it seems to be looking for libavformat.so.58
.
For now, in order to get it to work, I downloaded mpris.so
version 1.0 that doesn't have this dependency and placed it in ~/.var/app/com.github.iwalton3.jellyfin-media-player/data/jellyfinmediaplayer/scripts/
and it works really well.
For native mpris support in jmp, https://github.com/chrg127/mpris-server might be an option. Looks pretty small to set up. However, it is based on sdbus-c++, which I failed to integrate into the jellyfinmediaplayer build so far.
Another option would be implementing MPRIS on top of QDBusConnection
. This is what KDE Connect does, for example.
I think, the latter option might be what we want?
If I find time, I might take a further look into this topic
Edit: mpris_server
can quite easily be used; it needs c++20, though. Setting CXX_STANDARD
to 20, I get jmp to build (some implicit capture warnings, though). Not sure if raising CXX_STANDARD would be okay. I can then register as a mpris player that gets detected by playerctl
and also shows in the plasma taskbar.
Regarding hooking it up to jmp (the PlayerComponent?) and getting meta info/controlling the player, I found TaskbarComponentWin
that is connected to PlayerComponent
and InputComponent
. If a similar approach would be the right one, I am not sure.
@Kowalski7 your comment totally solved my issue! For any else coming to fedora silverblue / bazzite that used to use the unified remote server and are having issues with it, simple as grabbing the 1.0 release and copying into the flatpak path for JMP that kowalski listed. Now my media remote is working. Also i ended up moving to this app on android for remote media control over the unified remote one and im liking it alot, hope that helps someone else with HTPC build
On Arch Linux linking the library still did the trick and KDE Connect worked without further configuration.
$ ln -s /usr/lib/mpv-mpris/mpris.so ~/.local/share/jellyfinmediaplayer/scripts
on popOS the media keys in jellyfin media player application still not working when i press them on keyboard :(
I'm not sure if this is the case on Windows, but on Linux there's no media keys support. I'm not sure if this has to be done in the web wrapper or implemented manually, but there's a dbus interface for media key control.