Logger.configure(level: :info)
Mix.install([
:membrane_hackney_plugin,
:membrane_mp3_mad_plugin,
:membrane_portaudio_plugin
])
defmodule MyPipeline do
use Membrane.Pipeline
@impl true
def handle_init(_ctx, mp3_url) do
spec =
child(%Membrane.Hackney.Source{
location: mp3_url,
hackney_opts: [follow_redirect: true]
})
|> child(Membrane.MP3.MAD.Decoder)
|> child(Membrane.PortAudio.Sink)
{[spec: spec], %{}}
end
end
mp3_url =
"https://raw.githubusercontent.com/membraneframework/membrane_demo/master/simple_pipeline/sample.mp3"
{:ok, _supervisor, pipeline} = Membrane.Pipeline.start_link(MyPipeline, mp3_url)
Membrane.Pipeline.terminate(pipeline)