/** * 再生を開始する * * @param path 再生する音声のパス * @param notificationTitle Notificationに表示するタイトル。局名や番組名などを入れる。 * @param notificationContent Notificationに表示するタイトル。アーティスト名などを入れる。 */ private void play(String path, String notificationTitle, String notificationContent) { if (C.LOCAL_LOG) { Log.v(C.TAG, "trying to play " + path + "."); } if (path == null) { notifyPlayStateChanged(MSG_MEDIA_PLAY_SERVICE_FAILD_PLAY_START); return; } synchronized (mLock) { if (mMediaPlayer == null) { mMediaPlayer = new MediaPlayer(); mMediaPlayer.setOnCompletionListener( new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { synchronized (mLock) { mp.stop(); mp.setOnPreparedListener(null); mPlayingPath = null; mNotificationTitle = null; mNotificationContent = null; mp.reset(); } notifyPlayStateChanged(MSG_MEDIA_PLAY_SERVICE_PLAY_COMPLATED); changeState(new IdleState()); } }); } } mPlayState.play(path, notificationTitle, notificationContent); }
public void setTimeline(GameStateTimeline gst) { timeline = new AudioTimeline(gst); timeline.setTargetState(playState); timeline.addObserver((o, arg) -> playState.play()); }