Methods Summary |
---|
protected void | doClose()Subclasses need to implement this to close
the Player .
if(state != Player.UNREALIZED)
{
if(!stopped)
try{ doStop(); } catch (MediaException me) {}; // Make sure the we were stopped.
qsmc.close();
qsmc = null;
}
|
protected void | doDeallocate()Subclasses need to implement this to deallocate
the Player .
|
void | doFinishLoopIteration()
|
protected Control | doGetControl(java.lang.String controlType)The worker method to actually obtain the control.
Control r = null;
if ((getState() != UNREALIZED) && controlType.startsWith(ABBBasicPlayer.pkgName)) {
controlType = controlType.substring(ABBBasicPlayer.pkgName.length());
if (controlType.equals(ABBBasicPlayer.tocName)) {
r = tctrl;
} else
{
r = qsmc.getControl(controlType);
}
}
return r;
|
protected long | doGetDuration()Subclasses need to implement this to get the duration
of the Player .
return qsmc.getDuration();
|
protected long | doGetMediaTime()Subclasses need to implement this to get the media time
of the Player
return qsmc.getMediaTime();
|
void | doNextLoopIteration()
|
protected void | doPrefetch()Subclasses need to implement this to prefetch
the Player .
|
protected void | doRealize()Subclasses need to implement this to realize
the Player .
qsmc.open();
stopped = true;
if(source != null)
{
int count;
byte[] b = new byte[bufferSize];
// make use of BAOS, since it takes care of growing buffer
ByteArrayOutputStream baos = new ByteArrayOutputStream(bufferSize);
try {
while ((count = source.read(b, 0, bufferSize)) > 0)
baos.write(b, 0, count);
boolean r = qsmc.fillBuffer(baos.toByteArray());
baos.close();
if(!r) throw new MediaException("Bad Tone Format");
}
catch (IOException ioe)
{
throw new MediaException("Failure occured with read stream");
}
baos = null;
}
|
protected void | doSetLoopCount(int count)
qsmc.setLoopCount(count);
|
protected long | doSetMediaTime(long now)Subclasses need to implement this to set the media time
of the Player .
return qsmc.setMediaTime(now);
|
protected boolean | doStart()Subclasses need to implement this start
the Player .
/*
* TBD: wait until previous thread finishes before starting new one ...
* Does it make sense ? Or doStop() makes code below redundant ?
synchronized (playLock) {
if (playThread != null && playThread.isAlive()) {
//request thread to stop ex. stopped=true or doStop() ?
try { playThread.join(); } catch (InterruptedException ie) {};
}
}
*/
if(!stopped)
try{ doStop(); } catch (MediaException me) {}; // Make sure the we were stopped.
stopped = false;
synchronized(playLock)
{
playThread = new Thread(this);
playThread.start();
try { playLock.wait(); } catch (InterruptedException ie) {};
}
return true;
|
protected void | doStop()Subclasses need to implement this to realize
the Player .
qsmc.stop();
stopped = true;
synchronized(playLock)
{
try { playThread.join(); } catch (InterruptedException ie) {};
}
|
public java.lang.String | getContentType()
chkClosed(true);
return DefaultConfiguration.MIME_AUDIO_TONE;
|
public void | run()
qsmc.start();
synchronized(playLock) { playLock.notify(); }
boolean done = false;
int numLoopComplete = 0;
while(!stopped)
{
try { Thread.sleep(500); } catch (InterruptedException ie) {};
done = qsmc.isDone();
numLoopComplete = qsmc.numLoopComplete();
if(!done && (numLoopComplete > 0))
{
Long medt = new Long(qsmc.getMediaTime());
while(numLoopComplete-- > 0)
sendEvent(PlayerListener.END_OF_MEDIA, medt);
}
if (done)
stopped = true;
}
if(done) {
// updateTimeBase(false);
state = Player.PREFETCHED;
sendEvent(PlayerListener.END_OF_MEDIA, new Long(qsmc.getMediaTime()));
}
|
boolean | setSequence(byte[] seq)
if(state == UNREALIZED)
qsmc.open();
return qsmc.fillBuffer(seq);
|