public synchronized void reject() { // It must not be paused if you want to reject a track. setPaused(false); // Clear the toKeepPlaying flag to instruct the play thread to co-operatively stop. toKeepPlaying = false; if (player != null) player.close(); // Stop RoboJock if it's talking. if (speech != null && speaking) speech.abort(); }
private void playTrack() { try { synchronized (this) { speaking = playListManager.getTrackDatabase().isRoboJockEnabled(); // If a next track has been chosen by the user, use that, otherwise // pick one intelligently. currentTrack = nextTrack != null ? nextTrack : playListManager.chooseTrack(); toKeepPlaying = true; nextTrack = null; } if (currentTrack != null) { notifyUpdateListeners(); File file = currentTrack.getFile(); if (file.exists()) { if (speaking) { try { speech.say( (currentTrack.isRated() ? "" : "Unrated. ") + currentTrack.getTitle() + " by " + currentTrack.getArtist()); } catch (Exception e) { e.printStackTrace(); } finally { speaking = false; } } if (toKeepPlaying) { playFile(file); if (toKeepPlaying) { currentTrack.incNoOfTimesPlayed(); playListManager.getTrackDatabase().incNoOfPlays(); } } } else speaking = false; } } catch (Exception e) { e.printStackTrace(); } finally { try { sleep(500); } catch (InterruptedException e) { } } }
public boolean isSpeechSupported() { return speech.isSupported(); }