/**
   * Sets current source location. It can contain URL or path to local file. If playback is running,
   * stop() is pending. All buffering operations will be interrupted.
   *
   * @param sourceLocation URL or path to local file
   */
  public void setSourceLocation(String sourceLocation) {
    if (this.sourceLocation == null) this.sourceLocation = sourceLocation;
    else if (this.sourceLocation.equals(sourceLocation)) return;

    this.sourceLocation = sourceLocation;

    SeekablePumpStream pump;
    InputStream is;

    stop();
    synchronized (osync) {
      currentBufferedTimeMcsec = 0;
      currentPlayTimeMcsec = 0;
      currentSeekPositionMcsec = 0;

      pump = pumpStream;
      is = realInputStream;

      pumpStream = null;
      realInputStream = null;

      osync.notifyAll();
    }

    close(pump);
    close(is);
  }
Пример #2
0
 public void Restart() {
   if (player != null && !player.getSourceLocation().equals(null)
       || !player.getSourceLocation().equals("")) {
     player.stop();
     player.play();
   }
 }
 /**
  * Initiates playback stop and wait util it stops.
  *
  * @throws InterruptedException
  */
 public void stopSync() throws InterruptedException {
   stop();
   waitForState(PlayerState.STOPPED);
 }