* @exception MediaException thrown if setMediaTime fails.
* @return the new media time in microseconds.
*/
protected long doSetMediaTime(long now) throws MediaException {
if (seekType == NOT_SEEKABLE)
throw new MediaException("stream not seekable");
if (state == STARTED)
doStop();
if (now > duration)
now = duration;
mediaTimeOffset = now;
try {
int count = framePosControl.mapTimeToFrame(now);
//System.out.println("SetMediaTime to " + now + " (frame = " + count + "), frameCount=" + frameCount);
if (count + 1 < frameCount) {
// rewind to beginning
frameCount = 0;
seekFirstFrame();
}
// skip frames
while (frameCount <= count && getFrame())
// We need to decode all frames to have the correct pixels
// for frames with transparent color
decodeFrame();
displayTime = getDuration(frameCount) / 1000;
//System.out.println("SetMediaTime: displayTime = " + displayTime + "; frameCount=" + frameCount);
renderFrame();
if (state == STARTED)
// restart the player
doStart();
} catch (IOException e) {
throw new MediaException(e.getMessage());
}
return now;
}