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 keep move slider value according to audio play duration #64

Closed
AnilkumarDO opened this issue Jul 2, 2019 · 4 comments
Closed

Comments

@AnilkumarDO
Copy link

AnilkumarDO commented Jul 2, 2019

Thanks for the good library. We are using this, But, For the progress of the audio, We are showing Slider in UI. But, We have to keep move the progress bar status according to audio play.

Is there any method to get keep information about audio status?
And how to track buffering audio state? Is there any delegate method?
Also it is taking time to play URL like 5 to 10 seconds for online streaming, How to get is preparing play kind states?

@AnilkumarDO
Copy link
Author

I found solution myself by updating current time for state.

@jaccotaco
Copy link

Can you share your code?

@jaccotaco
Copy link

@AnilkumarDO

@smubarak-ali
Copy link

@jaccotaco
I have done something similar and pasting some code snippet below:

const { duration, currentTime } = info;
const elapsed = currentTime / duration;
const percetageElapsed = elapsed * 100;
this.setState({
currentTime: currentTime,
songDuration: duration,
elapsedInPercent: Math.round(percetageElapsed),
});

You can use the elapsedInPercent value to dynamically change the slider value or anything.

This whole function is wrapped around setInterval(() => ..., 2000), so it updates every 2 seconds. Also, don't forget to clearInterval on componentWillUnmount()

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

3 participants