Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Volume resets when loading new file in player #44

Open
lthomas122 opened this issue Feb 10, 2016 · 5 comments
Open

Volume resets when loading new file in player #44

lthomas122 opened this issue Feb 10, 2016 · 5 comments

Comments

@lthomas122
Copy link

When playing a track and setting the volume, if you change track the volume resets to the default volume of 90. The value of "Volume: " in the player's HTML will remain at the last value set, but the actual volume would have reverted to default.

I noticed on inspection of the JS (snippet below [Ln: 4734 - 4744]) that the volume controls only set the volume of the current track being played by SoundManager, as soon as another track is loaded, the getVolume() function is called again and returns the default volume, until you change the volume again via the controls.

getVolume: function() {
                return volume;
            },
adjustVolume: function(increase) {
                var changeVolume = function(volume) {
                    for(var i = 0; i < soundManager.soundIDs.length; i++) {
                        var mySound = soundManager.getSoundById(soundManager.soundIDs[i]);
                        mySound.setVolume(volume);
                    }
                    $rootScope.$broadcast('music:volume', volume);
                };
@NevenLeung
Copy link

@lthomas122 It seems a little difference between our case?

I use a tooltip to display the volume bar. When setting the volume value by dragging the volume bar, the the volume value displayed on webpage is fine. Everytime hovering on the volume button, the volume value is what I set before, but the volume value displayed on webpage is still 90.

I think we should change the value of volume variable displayed on the page in the meantime. But I don't know how to do that.

Any help is appreciated!!

@lthomas122
Copy link
Author

lthomas122 commented Sep 29, 2017 via email

@NevenLeung
Copy link

@lthomas122 Sorry! I didn't check the response here in time. Thanks for you help. I will be waiting for you solution.

@lthomas122
Copy link
Author

Can you explain the issue a little better for me @NevenLeung ?

Is it that the actual volume is resetting in the JavaScript, like my issue? Or is it that the UI is being a bit glitchy and resetting back to 90?

@lthomas122
Copy link
Author

lthomas122 commented Nov 22, 2017

if it's the actual volume not the volume UI controls. I've just written this script, which should point you in the right direction, however I've not tested it, as the project that I used soundmanager on ended years ago.

Hopefully this helps:

getVolume: function() {
            var sliderValue = document.getElementById('***PutSliderIdHere***').valueAsNumber;
            var savedVolume = Number(document.cookie.replace(/(?:(?:^|.*;\s*)appVolume\s*\=\s*([^;]*).*$)|^.*$/, "$1"));
            if ((volume != sliderValue ){
              volume = sliderValue;
              return volume;
            }
            else if(savedVolume.length){
              volume = savedVolume;
              sliderValue = savedVolume;
              return volume, sliderValue;            
              }
            else {
              return volume;
            }
            },
adjustVolume: function(increase) {
                var changeVolume = function(volume) {
                    for(var i = 0; i < soundManager.soundIDs.length; i++) {
                        var mySound = soundManager.getSoundById(soundManager.soundIDs[i]);
                        mySound.setVolume(volume);
                        document.cookie = "appVolume=" + volume;
                    }
                    $rootScope.$broadcast('music:volume', volume);
                };

ebroda added a commit to ebroda/angular-soundmanager2 that referenced this issue Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants