C
C#2y ago
maria 🌟

❔ Error with Naudio

I only can play the audio once and then no sound is played
5 Replies
maria 🌟
maria 🌟2y ago
class:
public class MP3Player
{
private WaveOut Player = new WaveOut();
private WaveStream blockAlignedStream;
public void Open(string FileName)
{
blockAlignedStream = new BlockAlignReductionStream(WaveFormatConversionStream.CreatePcmStream(new Mp3FileReader(System.IO.File.OpenRead(FileName))));


Player = new WaveOut(WaveCallbackInfo.FunctionCallback());
Player.Init(blockAlignedStream);
}

public void Play()
{
Player.Play();
}
}
public class MP3Player
{
private WaveOut Player = new WaveOut();
private WaveStream blockAlignedStream;
public void Open(string FileName)
{
blockAlignedStream = new BlockAlignReductionStream(WaveFormatConversionStream.CreatePcmStream(new Mp3FileReader(System.IO.File.OpenRead(FileName))));


Player = new WaveOut(WaveCallbackInfo.FunctionCallback());
Player.Init(blockAlignedStream);
}

public void Play()
{
Player.Play();
}
}
just play the sound once then never plays again :c
phaseshift
phaseshift2y ago
Streams can normally be read once. Are you calling Open for each Play?
reflectronic
reflectronic2y ago
just a guess: you need to do blockAlignedStream.Position = 0; once you want to re-start the playback
maria 🌟
maria 🌟2y ago
yes i have to seek the stream to 0 again thanks
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server