Hi, I'm trying to create a sound application, somewhat like Spotify using nAudio open source library. The application is only intended as a personal archive of my own song ideas. Most functionality works great but the WaveChannel32(New WaveFileReader) doesn't support URLs it seems.
Now, the sound files themselves lie in a folder on a server, which is also an SQL Server. I'm not sure on which approach would be the best to connect to the server and get the sound files. How would one actually connect to the server? Would one set up the server as a webserver? Would it be enough to specify the server IP-address?
And finally, how can I create an internet stream which the application can use? There should probably be some sort of buffering of the sound file first, running in one thread. And the actual playback running in a second thread? And how could I do this?
Edit: I've added the code I tried to convert to VB.NET, but I get the error message: Value of type 'System.IO.MemoryStream' cannot be converted to 'String'
The converted code looks like this:
Public Shared Sub PlayMp3FromUrl(ByVal url As String)
Using ms As New MemoryStream()
Using stream As Stream = WebRequest.Create(url).GetResponse().GetResponseStream()
Dim buffer As Byte() = New Byte(32768) {}
Dim read As Integer = 0
While (read = stream.Read(buffer, 0, buffer.Length)) > 0
ms.Write(buffer, 0, read)
End While
End Using
ms.Position = 0
Using blockAlignedStream As WaveStream = New BlockAlignReductionStream(WaveFormatConversionStream.CreatePcmStream(New Mp3FileReader(ms)))
Using waveOut As New WaveOut(0, 500, Nothing)
waveOut.Init(blockAlignedStream)
waveOut.Play()
While (blockAlignedStream.Position < blockAlignedStream.Length)
System.Threading.Thread.Sleep(100)
End While
End Using
End Using
End Using
End Sub