Skip to content
This repository was archived by the owner on Mar 28, 2026. It is now read-only.

Commit 6ccec74

Browse files
committed
Add MPRIS support
1 parent 7c41b87 commit 6ccec74

16 files changed

+2519
-7
lines changed

native/jmpInputPlugin.js

Lines changed: 399 additions & 4 deletions
Large diffs are not rendered by default.

native/mpvAudioPlayer.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,11 @@ class mpvAudioPlayer {
262262
setPlaybackRate(value) {
263263
this._playRate = value;
264264
window.api.player.setPlaybackRate(value * 1000);
265+
266+
// Notify MPRIS of rate change
267+
if (window.api && window.api.mpris) {
268+
window.api.mpris.notifyRateChange(value);
269+
}
265270
}
266271

267272
getPlaybackRate() {

native/mpvVideoPlayer.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,21 @@
594594
return this._supportedFeatures.includes(feature);
595595
}
596596

597+
isFullscreen() {
598+
// Check native window fullscreen state
599+
if (window.jmpInfo && window.jmpInfo.settings && window.jmpInfo.settings.main) {
600+
return window.jmpInfo.settings.main.fullscreen === true;
601+
}
602+
return false;
603+
}
604+
605+
toggleFullscreen() {
606+
// Toggle native window fullscreen directly via host command
607+
if (window.api && window.api.input) {
608+
window.api.input.executeActions(['host:fullscreen']);
609+
}
610+
}
611+
597612
// Save this for when playback stops, because querying the time at that point might return 0
598613
currentTime(val) {
599614
if (val != null) {
@@ -672,6 +687,11 @@
672687
let playSpeed = +value; //this comes as a string from player force int for now
673688
this._playRate = playSpeed;
674689
window.api.player.setPlaybackRate(playSpeed * 1000);
690+
691+
// Notify MPRIS of rate change
692+
if (window.api && window.api.mpris) {
693+
window.api.mpris.notifyRateChange(playSpeed);
694+
}
675695
}
676696

677697
getPlaybackRate() {

native/nativeshell.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,3 +554,30 @@ async function showSettingsModal() {
554554
});
555555
closeContainer.appendChild(close);
556556
}
557+
558+
// Monitor fullscreen state changes and notify MPRIS and web client
559+
let lastFullscreenState = window.jmpInfo.settings.main.fullscreen;
560+
561+
window.jmpInfo.settingsUpdate.push(function(section) {
562+
if (section === 'main') {
563+
const currentFullscreenState = window.jmpInfo.settings.main.fullscreen;
564+
if (currentFullscreenState !== lastFullscreenState) {
565+
console.log('Fullscreen state changed to:', currentFullscreenState);
566+
lastFullscreenState = currentFullscreenState;
567+
568+
// Notify MPRIS
569+
if (window.api && window.api.mpris) {
570+
window.api.mpris.notifyFullscreenChange(currentFullscreenState);
571+
console.log('MPRIS notified');
572+
}
573+
574+
// Notify web client UI (trigger fullscreenchange event)
575+
if (window.Events && window.playbackManager && window.playbackManager._currentPlayer) {
576+
console.log('Triggering fullscreenchange event on player');
577+
window.Events.trigger(window.playbackManager._currentPlayer, 'fullscreenchange');
578+
} else {
579+
console.log('Cannot trigger fullscreenchange - Events:', !!window.Events, 'playbackManager:', !!window.playbackManager, 'currentPlayer:', !!window.playbackManager?._currentPlayer);
580+
}
581+
}
582+
}
583+
});

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ add_subdirectory(system)
2222
add_subdirectory(settings)
2323
add_subdirectory(power)
2424
add_subdirectory(taskbar)
25+
add_subdirectory(mpris)
2526

2627
get_property(ALL_SRCS GLOBAL PROPERTY SRCS_LIST)
2728
set(MAIN_SRCS main.cpp)

src/core/ComponentManager.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#include "settings/SettingsComponent.h"
1414
#include "taskbar/TaskbarComponent.h"
1515

16+
#ifdef LINUX_DBUS
17+
#include "mpris/MprisComponent.h"
18+
#endif
19+
1620
#if KONVERGO_OPENELEC
1721
#include "system/openelec/OESystemComponent.h"
1822
#endif
@@ -59,6 +63,10 @@ void ComponentManager::initialize()
5963
registerComponent(&PowerComponent::Get());
6064
registerComponent(&TaskbarComponent::Get());
6165

66+
#ifdef LINUX_DBUS
67+
registerComponent(&MprisComponent::Get());
68+
#endif
69+
6270
#if KONVERGO_OPENELEC
6371
registerComponent(&OESystemComponent::Get());
6472
#endif

src/mpris/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
if(LINUX_DBUS)
2+
add_sources(MprisComponent.cpp MprisComponent.h)
3+
add_sources(MprisRootAdaptor.cpp MprisRootAdaptor.h)
4+
add_sources(MprisPlayerAdaptor.cpp MprisPlayerAdaptor.h)
5+
endif(LINUX_DBUS)

0 commit comments

Comments
 (0)