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

seekSeconds doesn't work for flac files #42

Open
HelgeStenstrom opened this issue Sep 12, 2019 · 5 comments
Open

seekSeconds doesn't work for flac files #42

HelgeStenstrom opened this issue Sep 12, 2019 · 5 comments

Comments

@HelgeStenstrom
Copy link
Collaborator

I have just tried a little, but it seems that seekSeconds doesn't work if the audio file is a flac file.

public long seekSeconds(int seconds) throws StreamPlayerException {
int durationInSeconds = this.getDurationInSeconds();
//Validate
validateSeconds(seconds, durationInSeconds);
//Calculate Bytes
long totalBytes = getTotalBytes();
double percentage = (seconds * 100) / durationInSeconds;
long bytes = (long) (totalBytes * (percentage / 100));
return seekBytes(this.getEncodedStreamPosition() + bytes);
}

Part of the problem is in TimeTool.durationInMilliseconds_Part2(), where the value on line 110 fall through if the file extension is not mp3, wav or ogg.

private static long durationInMilliseconds_Part2(final File file) {
long milliseconds = -1;
// exists?

This leads to an exception.
UnsupportedOperationException: Trying to skip with seconds {15} > maximum {-1}

If this value is changed to 1000000 (1000 seconds), this exception doesn't happen.
But the seek still doesn't happen.
That's as far as I have investigated.

See also https://github.com/HelgeStenstrom/java-stream-player/tree/appWithFlac

@goxr3plus
Copy link
Owner

That's true , i don't know why it happens :(

@ns96
Copy link

ns96 commented Dec 20, 2021

Also ran into this issue and it seems the underlying issue is with the org.jflac library not supporting skipping even when I worked around the issues with TimeTool. Hopefully, this issue can be fixed soon?

Dec 19, 2021 7:57:41 PM com.goxr3plus.streamplayer.stream.StreamPlayer seekBytes
WARNING: skip not supported
java.io.IOException: skip not supported at org.jflac.sound.spi.RingedAudioInputStream.skip(RingedAudioInputStream.java:374)

@goxr3plus
Copy link
Owner

Oups well to bypass that with XR3Player I used Jave2 library which I am a coauthor and converted everything to mp3 before playing them. So everything worked perfectly.

Have a look at Jave2 repository on github.

Well it's been time since I last supported this repo. I am a mobile and web developer now.

@goxr3plus
Copy link
Owner

@ns96
Copy link

ns96 commented Jan 31, 2022

Thanks for the info.

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

No branches or pull requests

3 participants