Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How would I go about a) restarting a sink and b) going back to a previous source? #634

Closed
yekyam opened this issue Nov 4, 2024 · 2 comments

Comments

@yekyam
Copy link

yekyam commented Nov 4, 2024

Hi y'all,

I was wondering how I could go back one using Sink. I know it has a skip_one method, but I can't figure out how I would go back one (one way I thought of is to append the previous track to the sink, but this feels hacky).

@dvdsk
Copy link
Collaborator

dvdsk commented Nov 5, 2024

Currently the hacky way is the way to do it I fear. We are in the process of completely redesigning the Sink api. The big secret of rodio is that you do not need Sink at all. It was added once to make things easier for users however since it cant do everything a lot of users get stuck there.

A "less" hacky method is to build your app without Sink, but that largely consists of making sink yourself, can be fun though. You can use OutputStreamHandle's play_raw to play a Source. That Source should be a SourcesQueueOutput. See rodio::queue. Then you can append your source followed by a EmptyCallBack. You use that to know when your source has ended. When that happens append another source to the SourcesQueueOutput via the SourcesQueueInput you got when you created the queue.

To skip one wrap your source in a Stoppable source. And to control that Stoppable wrap your source again now in a PeriodicAccess source. Inside that you put a closure from where you control the stoppable (see detailed example). Add other source wrappers as you need them (like seek/volume effects etc).

But there is nothing wrong with what you thought off. It should work :)

Whatever route you go down your feedback on rodio's current API would be very useful, please contribute it here: #626 if you have the time.

@yekyam
Copy link
Author

yekyam commented Nov 5, 2024

@dvdsk Hey, thank you so much for getting back to me so quickly!

The big secret of rodio is that you do not need Sink at all.

I had a feeling this was the answer, but I was just hoping to be lazy :P

Thanks for walking me through how I'd go about making my own Sink-like object, I'll try my hand at it and see how that takes me. I'm fairly inexperienced to Rust, but I don't think it'll be too bad.

Thanks again! And I'll be sure to contribute to that issue once I'm done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants