Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- synchronized public boolean play(int pos) {
- valid = true;
- canResume = false;
- try {
- FIS = new FileInputStream(path);
- total = FIS.available();
- if (pos > -1)
- FIS.skip(pos);
- BIS = new BufferedInputStream(FIS);
- player = new Player(BIS);
- LOGGER.debug("player in parent thread=" + player);
- Thread playThread = new Thread(new Runnable() {
- public synchronized void run() {
- try {
- LOGGER.debug("Playing " + path);
- post(new PlayStarted(path));
- setState(State.PLAYING);
- LOGGER.debug("player in child thread=" + player + ", may be waiting if null");
- if (player==null)
- wait();
- player.play();
- setState(State.STOPPED);
- post(new PlayStopped());
- } catch (Exception e) {
- LOGGER.error("Error playing mp3 file", e);
- valid = false;
- }
- }
- }, "playerThread");
- playThread.start();
- } catch (Exception e) {
- LOGGER.error("Error playing mp3 file", e);
- valid = false;
- }
- return valid;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement