naudio / NAudio

Audio and MIDI library for .NET
MIT License
5.58k stars 1.1k forks source link

Made an F# version of the example in https://github.com/naudio/NAudio/blob/master/Docs/PlayAudioFromUrl.md #1181

Open Ytrog opened 2 months ago

Ytrog commented 2 months ago

Hello,

I made an F# version of the code in https://github.com/naudio/NAudio/blob/master/Docs/PlayAudioFromUrl.md so I can easily listen to a certain radio-station on commandline. It might be of interest for documentation purposes:

open NAudio.MediaFoundation
open NAudio.Wasapi
open NAudio.Wave
open System.Threading

let url = "https://ice1.somafm.com/groovesalad-128-aac"

printfn "Starting Groove Salad Playback"

let start () =
    use mf = new MediaFoundationReader(url)
    use wo = new WasapiOut()

    wo.Init(mf)
    wo.Play()

    while true do
        Thread.Sleep 1000

start()