[Enhancement]: seekForward/Backward instead of next/previousTrack option #1102

Closed
opened 2026-04-24 23:32:27 +02:00 by adam · 14 comments
Owner

Originally created by @Alistair1231 on GitHub (Apr 25, 2023).

Describe the feature/enhancement

Hi!
Love the app. Thanks for your work.
I would love it, if there were an option to allow me to use my media keys, for skipping tracks forward/backwards, to instead of skipping an entire chapter, only skipping 10 seconds. In audiobooks I often simply miss what was said and want to hear it again. On android, the media keys simply skip back a bit, on desktop it skips entire chapters however. I rarely need to do that, and if I do I can just use the UI. Since other people may have different needs I feel an option is better, than just changing the current way it works.
I was playing around with the code, and found that in StreamContainer.vue on Lines 369 - 371 can be changed to easily accomplish the change in behaviour. I would've made a pull request. But I am hopelessly lost in how to make a settings option with my change instead of hardcoding it. My change is simply.
From this:

navigator.mediaSession.setActionHandler('previoustrack', this.mediaSessionPreviousTrack)
const hasNextChapter = this.$refs.audioPlayer && this.$refs.audioPlayer.hasNextChapter
navigator.mediaSession.setActionHandler('nexttrack', hasNextChapter ? this.mediaSessionNextTrack : null)

To this:

navigator.mediaSession.setActionHandler('previoustrack', this.mediaSessionSeekBackward)
navigator.mediaSession.setActionHandler('nexttrack', this.mediaSessionSeekForward)
Originally created by @Alistair1231 on GitHub (Apr 25, 2023). ### Describe the feature/enhancement Hi! Love the app. Thanks for your work. I would love it, if there were an option to allow me to use my media keys, for skipping tracks forward/backwards, to instead of skipping an entire chapter, only skipping 10 seconds. In audiobooks I often simply miss what was said and want to hear it again. On android, the media keys simply skip back a bit, on desktop it skips entire chapters however. I rarely need to do that, and if I do I can just use the UI. Since other people may have different needs I feel an option is better, than just changing the current way it works. I was playing around with the code, and found that in `StreamContainer.vue` on Lines 369 - 371 can be changed to easily accomplish the change in behaviour. I would've made a pull request. But I am hopelessly lost in how to make a settings option with my change instead of hardcoding it. My change is simply. From this: ```js navigator.mediaSession.setActionHandler('previoustrack', this.mediaSessionPreviousTrack) const hasNextChapter = this.$refs.audioPlayer && this.$refs.audioPlayer.hasNextChapter navigator.mediaSession.setActionHandler('nexttrack', hasNextChapter ? this.mediaSessionNextTrack : null) ``` To this: ```js navigator.mediaSession.setActionHandler('previoustrack', this.mediaSessionSeekBackward) navigator.mediaSession.setActionHandler('nexttrack', this.mediaSessionSeekForward) ```
adam added the enhancement label 2026-04-24 23:32:27 +02:00
adam closed this issue 2026-04-24 23:32:28 +02:00
Author
Owner

@advplyr commented on GitHub (Apr 26, 2023):

Hey are you using a keyboard for the media keys?

@advplyr commented on GitHub (Apr 26, 2023): Hey are you using a keyboard for the media keys?
Author
Owner

@advplyr commented on GitHub (Apr 26, 2023):

In the browser controls there is both seek and next track buttons.

image

Are you using something that doesn't have the seek buttons?

@advplyr commented on GitHub (Apr 26, 2023): In the browser controls there is both seek and next track buttons. ![image](https://user-images.githubusercontent.com/67830747/234431603-57a727cd-8084-48b1-b7d5-529ceee4ff81.png) Are you using something that doesn't have the seek buttons?
Author
Owner

@Alistair1231 commented on GitHub (Apr 26, 2023):

Yes I use my Keyboard. But even for keyboards without native support they can be emulated with AHK
Something like this for example (Ctrl+Alt+Left/Down/Right):

^!Left::Send {Media_Prev}
^!Down::Send {Media_Play_Pause}
^!Right::Send {Media_Next}

With the changes I mentioned in the issue description, I can now from any window, e.g. in a game, easily skip back a bit by pressing Media_Prev. The problem is, that there is no Keyboard key, or AHK key for that matter, that emlates the 'seekbackward'
or 'seekforward' keys. At least afaik.

The point for me is that I often listen to Audiobooks while gaming, where I cannot easily tab out and click around on media controls. Using a keyboard shortcut is no problem though. Also, it's simply easier and quicker to use the keyboard imo.

@Alistair1231 commented on GitHub (Apr 26, 2023): Yes I use my Keyboard. But even for keyboards without native support they can be emulated with [AHK](https://www.autohotkey.com/) Something like this for example (Ctrl+Alt+Left/Down/Right): ```AHK ^!Left::Send {Media_Prev} ^!Down::Send {Media_Play_Pause} ^!Right::Send {Media_Next} ``` With the changes I mentioned in the issue description, I can now from any window, e.g. in a game, easily skip back a bit by pressing Media_Prev. The problem is, that there is no Keyboard key, or AHK key for that matter, that emlates the 'seekbackward' or 'seekforward' keys. At least afaik. The point for me is that I often listen to Audiobooks while gaming, where I cannot easily tab out and click around on media controls. Using a keyboard shortcut is no problem though. Also, it's simply easier and quicker to use the keyboard imo.
Author
Owner

@advplyr commented on GitHub (Apr 26, 2023):

Ah ok so it doesn't support the seek forward/backward media keys?
https://developer.mozilla.org/en-US/docs/Web/API/Media_Session_API#setting_up_action_handlers_for_a_music_player

@advplyr commented on GitHub (Apr 26, 2023): Ah ok so it doesn't support the seek forward/backward media keys? https://developer.mozilla.org/en-US/docs/Web/API/Media_Session_API#setting_up_action_handlers_for_a_music_player
Author
Owner

@Alistair1231 commented on GitHub (Apr 26, 2023):

No, neither my Keyboard, nor Autohotkey support those. I also checked the Powertoys Keyboard Manager and couldn't see such a key. The typically well supported keys are Play/Pause, Stop, Prev Track and Next Track.
Outside of UI elements I have never encountered seekforward / seekbackward.

@Alistair1231 commented on GitHub (Apr 26, 2023): No, neither my Keyboard, nor Autohotkey support those. I also checked the Powertoys Keyboard Manager and couldn't see such a key. The typically well supported keys are Play/Pause, Stop, Prev Track and Next Track. Outside of UI elements I have never encountered seekforward / seekbackward.
Author
Owner

@advplyr commented on GitHub (Apr 27, 2023):

Are there other websites you use the media session keys for?

I just checked youtube.com and it looks like next/prev track isn't set for regular video. Maybe for a playlist. They are setting the seek forward/backward.

podcasts.google.com is showing both next/prev track and seeking. The next/prev track buttons actually seek like you are proposing here, so they have enabled both and they both do the same thing in my testing.

Curious if you have other examples

@advplyr commented on GitHub (Apr 27, 2023): Are there other websites you use the media session keys for? I just checked youtube.com and it looks like next/prev track isn't set for regular video. Maybe for a playlist. They are setting the seek forward/backward. podcasts.google.com is showing both next/prev track and seeking. The next/prev track buttons actually seek like you are proposing here, so they have enabled both and they both do the same thing in my testing. Curious if you have other examples
Author
Owner

@Alistair1231 commented on GitHub (Apr 27, 2023):

My main comparison would be how pretty much all Audiobook/Podcast players on Android work.
Android apps for audiobooks or podcasts, including the audiobookshelf app on Android, do seekbackward or seekforward when I use the media_prev or media_next keys on my Bluetooth headset.
On my PC, Audiobookshelf is the only app I use for this kind of content . So I don't have a lot of Apps to compare it to, except for how it works on my phone.

But in general, since Media_prev and Media_Next keys are far more common on keyboards as well as Bluetooth headsets, and users will on average more often want to skip forwards or backwards a bit instead of entire chapters, allowing for the remapping of this key would make sense in my opinion.

@Alistair1231 commented on GitHub (Apr 27, 2023): My main comparison would be how pretty much all Audiobook/Podcast players on Android work. Android apps for audiobooks or podcasts, including the audiobookshelf app on Android, do seekbackward or seekforward when I use the media_prev or media_next keys on my Bluetooth headset. On my PC, Audiobookshelf is the only app I use for this kind of content . So I don't have a lot of Apps to compare it to, except for how it works on my phone. But in general, since Media_prev and Media_Next keys are far more common on keyboards as well as Bluetooth headsets, and users will on average more often want to skip forwards or backwards a bit instead of entire chapters, allowing for the remapping of this key would make sense in my opinion.
Author
Owner

@Alistair1231 commented on GitHub (Apr 28, 2023):

I went ahead and gave the whole options thing a go, and I figured it out. I tried to keep all the conventions you use and made sure that the implmentation works. Also, be default I kept this option disabled.
If there are any issues let me know.

@Alistair1231 commented on GitHub (Apr 28, 2023): I went ahead and gave the whole options thing a go, and I figured it out. I tried to keep all the conventions you use and made sure that the implmentation works. Also, be default I kept this option disabled. If there are any issues let me know.
Author
Owner

@advplyr commented on GitHub (Apr 28, 2023):

I'm not sure if we need a setting for this. The reason I was asking if you had more examples is because I was thinking we just make both the media keys to seek forward/backward.

@advplyr commented on GitHub (Apr 28, 2023): I'm not sure if we need a setting for this. The reason I was asking if you had more examples is because I was thinking we just make both the media keys to seek forward/backward.
Author
Owner

@Alistair1231 commented on GitHub (Apr 28, 2023):

Personally, I think that would suffice. Though, it never hurts to provide options. There are all kinds of people with different habits out there. I would be fine either way.
Maybe the default could be to seek, with the option to enable skipping chapters?

@Alistair1231 commented on GitHub (Apr 28, 2023): Personally, I think that would suffice. Though, it never hurts to provide options. There are all kinds of people with different habits out there. I would be fine either way. Maybe the default could be to seek, with the option to enable skipping chapters?
Author
Owner

@Alistair1231 commented on GitHub (May 7, 2023):

Is there any update on this? Should I create a pull request that changes this behavior to be the default instead of adding an option or will you do it and are just busy?

EDIT: I just did that. Tiny change after all, so why bother you with it 😄

@Alistair1231 commented on GitHub (May 7, 2023): Is there any update on this? Should I create a pull request that changes this behavior to be the default instead of adding an option or will you do it and are just busy? EDIT: I just did that. Tiny change after all, so why bother you with it 😄
Author
Owner

@advplyr commented on GitHub (May 7, 2023):

Thanks yeah I think that is better for now. I was thinking of adding settings to the audio player instead of a server setting.

@advplyr commented on GitHub (May 7, 2023): Thanks yeah I think that is better for now. I was thinking of adding settings to the audio player instead of a server setting.
Author
Owner

@Alistair1231 commented on GitHub (May 7, 2023):

Thanks yeah I think that is better for now. I was thinking of adding settings to the audio player instead of a server setting.

Ah. Yeah, my solution would always apply to all users, which is suboptimal. Allowing the change on a user by user basis would be ideal, of course. Though, I am happy with simply changing the default behaviors and will close the issue now. If someone doesn't like it, they can create a new issue.

@Alistair1231 commented on GitHub (May 7, 2023): > Thanks yeah I think that is better for now. I was thinking of adding settings to the audio player instead of a server setting. Ah. Yeah, my solution would always apply to all users, which is suboptimal. Allowing the change on a user by user basis would be ideal, of course. Though, I am happy with simply changing the default behaviors and will close the issue now. If someone doesn't like it, they can create a new issue.
Author
Owner

@advplyr commented on GitHub (May 28, 2023):

Added in v2.2.21

@advplyr commented on GitHub (May 28, 2023): Added in [v2.2.21](https://github.com/advplyr/audiobookshelf/releases/tag/v2.2.21)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#1102