Re: [[Mod]Overlapping playback of 2 tracks of background music from the mod](how i can fix that?)
So yesterday I was trying to make a mod for opera gx for the first time and i went through the same problem @Mandi-OS had a while ago, I wanted to have 2 options of music but using the official template both were played at same time dynamically , after a lot of testing I found out why and how to fix it (to some degree), I am making this post hoping it will help people who face the same situation in the future.
A brief explanation:
As explained in this video here, with the official manifest layout if you list more than one music, the first music listed will always be played and any musics after it will be played as the the browser identifies actions like clicks, new tabs, etc. I think this is called dynamic background music.
Official manifest layout:
"background_music":
[
"music/track_1.mp3", <- always playing
"music/track_2.mp3" <- from this point on, they will be played dynamically
],
If you want to make it play one music and then another, unfortunately as far as I know you need to unite the musics into one through an music editor and only add the united version of the musics.
But if instead you want to have many musics in a single Mod so the final user can select the one they want, i found this alternative:
"background_music": [
{
"id": "music1",
"name": "track_1_name",
"author": "author_1",
"tracks": [
"music/track_1.mp3"
],
"Description": "track_1 of author_1"
},
{
"id": "music2",
"name": "track_2_name",
"author": "author_2",
"tracks": [
"music/track_2.mp3","music/track_2.mp3"
],
"Description": "track_1 of author_1"
}
],
In case someone doesn't understand the structure, "id" identifies the music, "name" is the name displayed in background music configuration tab, if you don't provide an "author" your "developer": {"name": "your_name"} is shown as the author of the music, in "tracks" you can list one or many musics (many if you want dynamic background music),i assume "Description" exists since it didn't trigger any errors and the native background musics of the browser have one but it's not shown in opera://settings/background_music_settings, so it's completely optional.
If anyone finds a way to play one music and then another without uniting the musics feel free to reply this post, I tried looking through a lot of reddit, opera forums posts, github docmuentation and youtube videos and didn't find anything relevant, I feel lucky I even managed to find a solution for having many musics in a single Mod on my own.