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

Is there a programmatic way to control the volume of individual tracks? #34

Closed
alexander-daniel opened this issue Dec 15, 2016 · 6 comments
Labels

Comments

@alexander-daniel
Copy link
Contributor

I'm try to write my own UI for the individual track controls. I can emit easily to adjust master volume, but it seems like the track volumes are a bit tougher to get access to.

Any ideas?

By the way, thanks for the awesome module, this thing is the best!

@Willena
Copy link
Contributor

Willena commented Dec 15, 2016

Yeah, that's right. May be it could be a future feature to add.

For now you can change the track volume by changing the gain property on a track object: playlist.tracks[0].gain = 0.2
but you will need to restart the player ( click play/pause ) so that it can be taken into acount.

@alexander-daniel
Copy link
Contributor Author

@Willena Awesome, thanks!

Yup, from my explorations that was the only way to get it to update the track gain. Will roll with that for now, but it would be super cool to update in real-time the same way the master settings can be emitted and changed

@alexander-daniel
Copy link
Contributor Author

alexander-daniel commented Dec 15, 2016

@Willena Actually, it IS possible!

Just looked into the src:

https://github.com/naomiaro/waveform-playlist/blob/master/src/Playlist.js#L218

and in my code I did: (sorry its contextual, but i basically just get the track object I'm interested in and pass that into the emit function parameters.

function setGain(trackID, gain) {
    const track = getTrackByID(trackID);
    playlist.ee.emit("volumechange", gain * 100, track);
}

no need for the play/pause dance!

@naomiaro
Copy link
Owner

Aha! Did this event miss the README? Some of the events previously I had not written in the docs, and had just used them myself. I'll have to update that.

Glad you like the lib!

@alexander-daniel
Copy link
Contributor Author

@naomiaro All good, I should have looked in the src right away! Super clean and easy to see whats going on once you take the plunge.

I might have a few more questions in the following days, but this is great and does what I need it re: gain setting of tracks, so I'll close this! (Unless you want to keep it open until you update the docs)

Cheers!

@naomiaro
Copy link
Owner

Yeah I'll close it when I update the docs, @alexander-daniel thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants