LiveSplit / LiveSplit/LiveSplitOne
Global Hotkeys via Media Session
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 301
- Forks
- 55
- Avg merge
- 8m
- Merged PRs (30d)
- 1
Description
Looks like it is indeed possible to have yet another form of global hotkeys. We can start a media session and pretend we are playing music, at which point the browser will forward any key presses of the media keys on your keyboard (or any other way of pausing, playing, skipping, ... the current song, such as pressing buttons on your headphones) to custom JavaScript code you can execute:
https://developer.mozilla.org/en-US/docs/Web/API/MediaSession
```js
if ('mediaSession' in navigator){
navigator.mediaSession.metadata = new MediaMetadata({
title: "Podcast Episode Title",
artist: "Podcast Host",
album: "Podcast Name",
artwork: [{src: "podcast.jpg"}]
});
navigator.mediaSession.setActionHandler('play', function() {});
navigator.mediaSession.setActionHandler('pause', function() {});
navigator.mediaSession.setActionHandler('seekbackward', function() {});
navigator.mediaSession.setActionHandler('seekforward', function() {});
navigator.mediaSession.setActionHandler('previoustrack', function() {});
navigator.mediaSession.setActionHandler('nexttrack', function() {});
}
```
Seems like you may need to play some actual audio or so for this to work.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked MDN MediaSession documentation and verify browser support, including whether active audio is required. Then locate the application's existing global-hotkey entry point and determine how media actions should connect to it. Done means supported media-key actions reliably invoke the intended handlers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100