Background Player() audio

Is it possible to use the javascript

Player() api to play a sound file (mp3) in the background just like the background audio element


<background>
     <audio>
        <asset src="<URL>" />
     </audio>
</background>


I am trying to use a catalog template for all the video assets in a show and want to play the show theme music lightly in the background. My challenge is that when the user clicks on a tile for a video I push a new view with all the video information and the background audio element stops since a new view was pushed.


My thought was to use the player api, call the music file on the initial view and can stop the player and load the video element when they finally hit the play button on the asset viewer page.


The example below works to play audio elements but when the play command is called it takes over the view and I don't see anywhere in the docs where you can call a player with audio assets to play in the background.

var player = new Player();
var playlist = new Playlist();
var mediaItem = new MediaItem("audio","<URL>");
player.playlist = playlist;
player.playlist.push(mediaItem);
player.play();


Thoughts?

Answered by in 57463022

It is possible for you to continue the background audio playback on the new page you push by specifying the same audio asset on the new page.


However it is not possible to use the Player API to play music in the background. Please file an enahancement request with your use case.

Accepted Answer

It is possible for you to continue the background audio playback on the new page you push by specifying the same audio asset on the new page.


However it is not possible to use the Player API to play music in the background. Please file an enahancement request with your use case.

Thanks Nurinder, your recomendation worked.

Background Player() audio
 
 
Q