Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2015
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1.     synchronized public boolean play(int pos) {
  2.         valid = true;
  3.         canResume = false;
  4.         try {
  5.             FIS = new FileInputStream(path);
  6.             total = FIS.available();
  7.             if (pos > -1)
  8.                 FIS.skip(pos);
  9.             BIS = new BufferedInputStream(FIS);
  10.             player = new Player(BIS);
  11.             LOGGER.debug("player in parent thread=" + player);
  12.             Thread playThread = new Thread(new Runnable() {
  13.                 public synchronized void run() {
  14.                     try {
  15.                         LOGGER.debug("Playing " + path);
  16.                         post(new PlayStarted(path));
  17.                         setState(State.PLAYING);
  18.                         LOGGER.debug("player in child thread=" + player + ", may be waiting if null");
  19.                         if (player==null)
  20.                             wait();
  21.                         player.play();
  22.                         setState(State.STOPPED);
  23.                         post(new PlayStopped());
  24.                     } catch (Exception e) {
  25.                         LOGGER.error("Error playing mp3 file", e);
  26.                         valid = false;
  27.                     }
  28.                 }
  29.             }, "playerThread");
  30.             playThread.start();
  31.         } catch (Exception e) {
  32.             LOGGER.error("Error playing mp3 file", e);
  33.             valid = false;
  34.         }
  35.         return valid;
  36.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement