Click here to Skip to main content
15,884,237 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I made a UserControl to play an MP3, with a slider, so that when I use two or more Usercontrols I can play the MP3 and use the slider to lower the volume apart for each MP3. Using the Volume control on WaveOut() itself worked, but then the volume of all UserControls went up and down. So I found somewhere I should use a SampleChannel and set the Volume there : BINGO. But now, when I listen using my headphones, and set the Headphone volume on the computer to 100%, the volume is much lower than not using the SampleChannel.... Weird

private void slider1_Scroll(object sender, ScrollEventArgs e)
{
if (_inputStream != null) _inputStream.Volume = sliderVolume.Value / 100f;
}

private Mp3FileReader _fileStream;
private SampleChannel _inputStream;
private WaveOut _player;

private void button1_Click(object sender, EventArgs e)
{
_fileStream = new Mp3FileReader(_path);
_inputStream = new SampleChannel(_fileStream) {Volume = sliderVolume.Value / 100f};


_player = new WaveOut();
_player.Init(_inputStream);
_player.Play();

//player.PlaybackStopped += _player_PlaybackStopped;
}

What I have tried:

I tried to use directly the WaveOut() volume... worked, but then the slider lowered all the other mp3 volumes too.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900