Need to apply seeking in ogg playing using Java -
Need to apply seeking in ogg playing using Java -
i have been working multi-platform desktop application need implement both mp3 , ogg player including seeking, mp3 part ok, seeking in ogg play not working...
i using basicplayer
of javazoom.jlgui , next seek function
/** * skip bytes in file inputstream. skip n frames matching * bytes, never skip given bytes length exactly. * * @param bytes * @return value>0 file , value=0 url , 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 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 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(); } } homecoming totalskipped; }
is there way add together seek function implement seek ogg? in advance...
don't know much how works,but works fine mp3 including seeking, sound play,pause,stop in ogg playing,pause,stop fine, seeking problem, when seeked sound playing starts beginning.
i didn't alter part of code source of basicplayer api http://www.javazoom.net/jlgui/sources/basicplayer3.0.zip
when checked details in depth, jlgui3.0 player implemented using code not implemented seeking ogg play, have mentioned it. current code needs added separate seek function ogg playing , utilize instead of current seek()
, whenever playing sound ogg...
i don't know how so, help me source refer , easy way implement same...
i think library may not sufficient needs. looking @ source code of jlgui, (pasted below) seeking supported .mp3 files , .wav files.
moreover, logic behind naive, because hops forwards fixed number of bytes. pcm format .wav files, number of bytes skipped proportional amount of time skipped, variable bit rate .mp3 files, amount of time skip vary instantaneous bitrate @ different points in file. ogg vorbis container format supports multiplexing, makes seeking more complicated jumping ahead in file , resynchronizing decoder.
as alternative, recommend using javasound or javafx apis, both can play sound files , seek time provide, rather byte offset.
from jlgui:
protected void processseek(double rate) { seek { if ((audioinfo != null) && (audioinfo.containskey("audio.type"))) { string type = (string) audioinfo.get("audio.type"); // seek back upwards mp3. if ((type.equalsignorecase("mp3")) && (audioinfo.containskey("audio.length.bytes"))) { long skipbytes = (long) math.round(((integer) audioinfo.get("audio.length.bytes")).intvalue() * rate); log.debug("seek value (mp3) : " + skipbytes); thesoundplayer.seek(skipbytes); } // seek back upwards wav. else if ((type.equalsignorecase("wave")) && (audioinfo.containskey("audio.length.bytes"))) { long skipbytes = (long) math.round(((integer) audioinfo.get("audio.length.bytes")).intvalue() * rate); log.debug("seek value (wave) : " + skipbytes); thesoundplayer.seek(skipbytes); } else posvaluejump = false; } else posvaluejump = false; } grab (basicplayerexception ioe) { log.error("cannot skip", ioe); posvaluejump = false; } }
java ogg seek multiplatform audio-player
Comments
Post a Comment