How can I disable "seekto" in mediaSession?

168 Views Asked by At

Please I need help.

How can I disable seekto in mediaSession? I don't know if I'm getting the name correctly but I'll attach a screenshot with an arrow pointing to it so you can understand better.

This is what I'm talking about

navigator.mediaSession.setActionHandler("seekto", null);

The code above doesn't hide seekto. I expect it to hide it just like in the screenshot below. This is the final result I'm seeking for.

This is the final result I'm asking for

Your help will be highly appreciated.

2

There are 2 best solutions below

3
Griffin Amaral On

While this won't remove it you can remove null and set it to an empty callback function which should render the seekto functionality as useless.

navigator.mediaSession.setActionHandler("seekto", function(details) {});
0
Juan Pablo Azambuyo On

Maybe this code will help you..

navigator.mediaSession.setPositionState({
  duration: 0,
  playbackRate: 1,
  position: 0
})

This code works fine with an silence.mp3 (inaudible mp3) and of course with an <audio> tag.. I don't try it with a playing sound, I just use this workaround to handle the notification bar the way I want.