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

How to obtain the current playing time and position when rodio plays music files #457

Closed
yunfengwangluo opened this issue Dec 3, 2022 · 1 comment · Fixed by #585
Closed

Comments

@yunfengwangluo
Copy link

How to obtain the current playing time and position when rodio plays music files

At present, I want to try to build a simple music playing software,

Music playing software needs the most basic

"Total duration" of music files

Current play position "Play time position"

Jump to the specified position "Time Position"

I don't know how to get the "play time position" at present

Thank you for your help

@BastianHentschel
Copy link

BastianHentschel commented Sep 7, 2023

Does the functionality in #510 fulfill the "Play Time Position"?

Total Duration should be possible with Source::total_duration() although as far as i saw only the flac decoder does actually provide the relevant API.

It should be quite easy to add it to the symphonia decoders, as long as the relevant header parts are filled in the music files.

Gusted added a commit to Gusted/rodio that referenced this issue Jun 9, 2024
This adds a new PositionTrack trait which counts the amount of times
`next()` is called (where it returns `Some`) and provide a function to
get the position, which is a simple calculation.

This is added to the Sink struct by default and the accuracy of this depends on
the interval of `periodic_access`.

I wasn't able to add testing to the sink counter part, because I
wanted to also test `try_seek`, but it seems like I would need to have
some threading code to call `next` on sink in another thread, which
didn't look that good and resulted in a flaky test so only a 'unit test'
in ``position.rs`.

Resolves RustAudio#457
Closes RustAudio#510
Gusted added a commit to Gusted/rodio that referenced this issue Jun 9, 2024
This adds a new TrackPosition trait which counts the amount of times
`next()` is called (where it returns `Some`) and provide a function to
get the position, which is a simple calculation.

This is added to the Sink struct by default and the accuracy of this depends on
the interval of `periodic_access`.

I wasn't able to add testing to the sink counter part, because I
wanted to also test `try_seek`, but it seems like I would need to have
some threading code to call `next` on sink in another thread, which
didn't look that good and resulted in a flaky test so only a 'unit test'
in ``position.rs`.

Resolves RustAudio#457
Closes RustAudio#510
@dvdsk dvdsk closed this as completed in e1108ab Jun 17, 2024
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

Successfully merging a pull request may close this issue.

2 participants