Hello everyone in the Elixir Membrane community! I've recently taken an interest in Membrane and have started learning about it. I've been working with Elixir for about three years, so I am fairly comfortable with Elixir. However, I'm not very familiar with media-related technologies, so I'm facing some challenges. While going through the tutorials, I've come across a question. Below is a demo provided by Membrane that reads a music file and outputs it to a speaker. How can I make the music play automatically again after it ends? To put it in terms of a music player, I would like to implement a loop feature. If you have any good ideas, or if there are documents or code that I should look into further, your guidance would be greatly appreciated.
def handle_init(_ctx, path_to_mp3) do
# Setup the flow of the data
# Stream from file
spec =
child(:file, %Membrane.File.Source{location: path_to_mp3})
# Decode frames
|> child(:decoder, Membrane.MP3.MAD.Decoder)
# Convert Raw :s24le to Raw :s16le
|> child(:converter, %Membrane.FFmpeg.SWResample.Converter{
output_stream_format: %Membrane.RawAudio{
sample_format: :s16le,
sample_rate: 48000,
channels: 2
}
})
# Stream data into PortAudio to play it on speakers.
|> child(:portaudio, Membrane.PortAudio.Sink)
{[spec: spec], %{}}
end