Audio Streaming

Hi, I'm trying to make online radio stream platform. I use dioxus for frontend and axum for backend.
I can play streamed audios with basic html audio component. Problem is I don't know how to stream my own audio. I know basics of axum but if there are any other easy way to implement audio stream, I'm also interested. Thanks.

Yeah, I'm also intersted.
But even if I knew an answer I couldn't help u cause I'm basically using 'warp'.
If sb knows how to do it plz help. I'm also intersted how to stream a video

Are you looking for webrtc/examples at master · webrtc-rs/webrtc · GitHub ?

thx, I'll check this out

Can't I just create byte stream from mp3 file or something. Do I really need to use webrtc ? I'm asking because I don't know, please don't understand me wrong.

WebRTC is appropriate where low latency is required (voice chat, other interactive applications). It is not necessary for music streaming.

What do you recommend for music streaming ?

In principle, all you need to do is create a HTTP response whose body is an MP3 data stream that keeps on going. But I haven't done that in Rust, so I can't recommend you any libraries.

3 Likes

With actix-web it is fairly easy to create a streaming http response from a Stream with the HttpResponseBuilder::streaming method. I don't know the equivalent in axum, but I'm sure it is supported. If you have an mp3 file, you could load it with tokio::fs::File and wrap it in a tokio_util::io::ReaderStream to get a byte stream you can use as the payload of your response.

1 Like