This project has moved and is read-only. For the latest updates, please go here.

Playing WMA

Dec 28, 2011 at 2:50 PM
Edited Dec 29, 2011 at 12:19 AM

First off I just found this library and I love it. I have been able to play WAV and MP3 with no problem. However when I try to play WMA nothing happens even though when debugging it reports the state is still playing. So if you could possibly point out my problem it would be great. Here is my code, sorry it is in Vb...

 

    Sub Main()
Dim waveoutdevice As IWavePlayer
Dim mainoutputstream As WaveStream
waveoutdevice = New WasapiOut(AudioClientShareMode.Shared, 100)
mainoutputstream = CreateInputStream("\Test.wma")
waveoutdevice.Init(mainoutputstream)
waveoutdevice.Play()
Do While waveoutdevice.PlaybackState <> PlaybackState.Stopped
Threading.Thread.Sleep(100)
Loop
waveoutdevice.Dispose()
mainoutputstream.Dispose()
End Sub
Private Function CreateInputStream(ByVal fileName As String) As WaveStream
Dim inputStream As WaveChannel32

If fileName.EndsWith(".mp3") Then
Dim mp3Reader As WaveStream = New Mp3FileReader(fileName)
inputStream = New WaveChannel32(mp3Reader)
ElseIf fileName.EndsWith(".wav") Then
Dim wavreader As WaveStream = New WaveFileReader(fileName)
inputStream = New WaveChannel32(wavreader)
ElseIf fileName.EndsWith(".wma") Then
Dim wmareader As WaveStream = New WMAFileReader(fileName)
inputStream = New WaveChannel32(wmareader)
Else
Throw New InvalidOperationException("Unsupported extension")
End If
Return inputStream
End Function
Jan 3, 2012 at 1:41 PM

if MP3 and WAV are playing, then there is likely nothing wrong with your code and you have found a problem with WMA file reader (which is fairly new to NAudio and hasn't been extensively tested yet). If you are able to step into NAudio code then you could see what the WMAFileReader.Read method is doing

Mark

Jan 4, 2012 at 7:22 PM

[quote]if MP3 and WAV are playing, then there is likely nothing wrong with your code and you have found a problem with WMA file reader (which is fairly new to NAudio and hasn't been extensively tested yet). If you are able to step into NAudio code then you could see what the WMAFileReader.Read method is doing

Mark[/quote]

Thanks for the reply Mark. I really don't have have the time to figure it out... But I think will will simply just drop support for WMA in my app for now. WAV, MP3 are really the only formats I need. Thanks for your time.