Skip to content
Advertisement

JavaScript Audio Object how to play next track on clicking next

I am making a music web app where users can load song or load array of music. I tried to make a button where user can skip the track and play the next track from the array. I tried in my own method and it actually working quiet well.

heres my music object:

JavaScript

and in audio player:

JavaScript

It works perfectly but the problem of it is, i cannot change/skip the track from browser control. for eg:- in soundcloud and other apps If i am using it in mobile then i can skip the track from my lockscreen, There will be a small browser audio control and we can skip it from there. But from my app i cant do that for some reason.

heres the picture of what i am talking about:

soundcloud:

enter image description here

myapp:

enter image description here

as you can see here I cant control it from here. Where as in sound cloud i can change the tracks. And in soundlocud, it also displays title of the song where as in my it doesnt, it just displays title of my page.

I am using react for the development

Advertisement

Answer

Please checkout MediaSession documentation

Media Session Doc

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement