I have been working for a multi-platform desktop application that need to implement both mp3 and ogg player including seeking, Now my mp3 part is Ok, but seeking in ogg play is not working...
I am using BasicPlayer of javazoom.jlgui and following is my seek function
/**
* Skip bytes in the File inputstream. It will skip N frames matching to
* bytes, so it will never skip given bytes length exactly.
*
* @param bytes
* @return value>0 for File and value=0 for URL and InputStream
* @throws BasicPlayerException
* @throws IOException
*/
protected long skipBytes(long bytes) throws BasicPlayerException, NullPointerException, IOException {
long totalSkipped = 0;
if (m_dataSource instanceof File) {
log.info("Bytes to skip : " + bytes);
int previousStatus = m_status;
m_status = SEEKING;
long skipped = 0;
synchronized (m_audioInputStream) {
notifyEvent(BasicPlayerEvent.SEEKING, getEncodedStreamPosition(), -1, null);
initAudioInputStream();
if (m_audioInputStream != null) {
// Loop until bytes are really skipped.
while (totalSkipped < (bytes - SKIP_INACCURACY_SIZE)) {
skipped = m_audioInputStream.skip(bytes - totalSkipped);
if (skipped == 0) {
break;
}
totalSkipped = totalSkipped + skipped;
log.info("Skipped : " + totalSkipped + "/" + bytes);
if (totalSkipped == -1) {
throw new BasicPlayerException(BasicPlayerException.SKIPNOTSUPPORTED);
}
}
}
}
notifyEvent(BasicPlayerEvent.SEEKED, getEncodedStreamPosition(), -1, null);
m_status = OPENED;
if (previousStatus == PLAYING) {
startPlayback();
} else if (previousStatus == PAUSED) {
startPlayback();
pausePlayback();
}
}
return totalSkipped;
}
is there any way to add another seek function to implement seek for ogg? thanks in advance...
Don't know much about how this works,but it works fine for mp3 including for seeking, audio play,pause,stop In ogg playing,pause,stop are fine, but seeking is the problem, when seeked audio playing starts from the beginning.
I didn't change any part of the code source of BasicPlayer Api is http://www.javazoom.net/jlgui/sources/basicplayer3.0.zip
when I checked details in depth, jlgui3.0 player implemented using this code is also not implemented seeking for Ogg play, they have mentioned it. So the current code needs to be added with a separate seek function for Ogg playing and use it instead of current seek(), whenever the playing audio is Ogg...
I don't know how to do so, help me with good source to refer and easy way to implement the same...
else if (previousStatus == PAUSED) { startPlayback(); pausePlayback(); }? (I may be ignorant of how your program works butstart-> immediatelypauseseems suspicious.) - Radiodef(x4F\x67\x67\x53), then you go 6 bytes ahead and from 7 to 14th byte you read Granule Pos (8 Bytes). Now the complication is: WHAT'S AUDIO CODEC? Flac, Opus, Vorbis? GranulePos could mean how many PCM samples decoded so far (samples = time) - VC.One