Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Global Media Key Control #477

Open
jwmay2012 opened this issue May 10, 2022 · 0 comments
Open

Feature Request: Global Media Key Control #477

jwmay2012 opened this issue May 10, 2022 · 0 comments

Comments

@jwmay2012
Copy link

jwmay2012 commented May 10, 2022

Feature suggestion

Capture and forward global media key presses from keyboard to Kodi.

Using chorus UI, select an album/playlist for kodi to play.
Play/Pause, Prev/Next, (and maybe volume?) button presses control media playback in Kodi, as if you were controlling a playback app on your computer/browser.

Similar to playback control from Jellyfin/Plex/any_other_browser_media_player.

Use Case / Why? / Context

When I'm at my desk, I can just use the media source directly (Jellyfin) to play music locally and have my media keys control the player.

However, sometimes I want to work with my laptop in the living room where my TV w/Kodi is, so I'm looking for a way to queue up an album/playlist on Kodi and have media keys (play/pause, next/prev, volume) be directed to Kodi.

Possible Implementation

https://developer.mozilla.org/en-US/docs/Web/API/Media_Session_API

Just spent some time tinkering in the console.
I have no idea what I'm doing within the scope of your project, but here's a POC.

// Begin playing silent audio. MediaSession API doesn't function unless its playing something
this.audioTag = document.createElement('audio');
document.body.appendChild(this.audioTag);
this.audioTag.src = "https://raw.githubusercontent.com/anars/blank-audio/master/10-seconds-of-silence.mp3";
this.audioTag.loop = true;
this.audioTag.play();

// grab player to send commands and make it global
player = this.Kodi.kodiPlayer;

// set media session api action handlers for play/pause next/prev
navigator.mediaSession.setActionHandler('play', function() { player.triggerMethod("control:play") });
navigator.mediaSession.setActionHandler('pause', function() { player.triggerMethod("control:play") });
navigator.mediaSession.setActionHandler('nexttrack', function() { player.triggerMethod("control:next") });
navigator.mediaSession.setActionHandler('previoustrack', function() { player.triggerMethod("control:prev") });

The Play/Pause next/prev media key now control Kodi.

Thanks for your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants