WebSnke / Nintendo-3DS-Music

Listen to the Nintendo 3DS Music while adjusting your settings or shopping. Feel free to contribute!
https://addons.mozilla.org/en-US/firefox/addon/nintendo-3ds-music/
GNU General Public License v3.0
6 stars 4 forks source link

Add "fadeOutAudio()" to background.js #8

Closed AFellowSpeedrunner closed 7 months ago

AFellowSpeedrunner commented 7 months ago

Not sure if it's entirely perfect but at least it works. Didn't like how it abruptly cuts off so I decided to add some sort of fade out code to the background.js file.

AFellowSpeedrunner commented 7 months ago

I have absolutely no clue why it re-added the other changes but I did yesterday that were already merged. Wouldn't break anything anyways.

I'm not the best at this but this should help it sound a lot more natural with the fade out when switching sites without an abrupt stop to the song.

AFellowSpeedrunner commented 7 months ago

Everything should now be fixed!

AFellowSpeedrunner commented 7 months ago

Alright, I'm going to test it in a minute or so. I'll report back if everything works okay.

AFellowSpeedrunner commented 7 months ago

Found an issue I had when originally adding this, pop up again. It isn't fading out all the way with 0.01. I remember setting it to 0.001 fixed it. Also, now it doesn't go back up when switching tabs due to this. Going to see if something broke that bit.

AFellowSpeedrunner commented 7 months ago

This should hopefully fix it. Reason why it wouldn't go down all the way is because it kept trying to set it negative and it really doesn't like that causing hundreds upon thousands of errors to happen within seconds. Eventually, this will cause Firefox (at least on my MacBook) to lock and cause the system to start slowing down. My code now fixes that by clamping volumes to 0 minimum.

Edit: it also fully fades out now and it restarts playback with previous volume as well. works with other songs too.

AFellowSpeedrunner commented 7 months ago

Alright, committed them over.

AFellowSpeedrunner commented 7 months ago

Nice, thanks for the merge!