Closed yuvadm closed 1 month ago
Also, this is might be related to ongoing seek behavior changes i.e. #176 ?
That's actually a different kind of seek :)
The problem is your MediaSourceStream does not implement the right IO traits. Instead of fixing that you might be better of using something like: https://github.com/aschey/stream-download-rs
If you want to do this yourself take a look at what the decoder needs. Basically you'll have to write a struct that wraps the reqwest output and implements the Read and Seek traits while it is also Send and Sync. Thats not easy as you want to download while playing so you need multiple threads.
Ive been working on something like this myself but its not fully done yet
@dvdsk thanks for the quick response! Would stream-download-rs
be the right approach even if I'm doing blocking IO / threads? Generally speaking I don't require async
, but I do want the easiest interface for hooking up a stream to rodio.
I've bumped into the recommendation in #439 but minimp3
seems to be a rather broken approach.
I recommend you read through https://tokio.rs/tokio/topics/bridging. Almost all of rusts io-libs (reqwest::blocking
in your code snippet above does the same as described in the article above. ) are async under the hood, even if the provide a blocking API. Once you get the whole bridging async and non-async code bit it isn't a big deal anymore.
Appreciate the clarification, indeed stream-download-rs
does the job and has great useful examples.
I'm trying to run a basic scenario of playing an MP3 stream from network by using a
ReadOnlySource
fromsymphonia
.This is my current usage:
While this does compile, it fails with:
What would be the right way to use a non-seeking source? Ideally would like to use any available pre-existing traits from symphonia/rodio, but can also implement any custom traits as necessary.