AudioPlayer implements MediaPlayerControl, OnPreparedListener { public MediaPlayer play(Episode episode) throws IOException { mediaPlayer.setAudioStreamType(STREAM_MUSIC); mediaPlayer.setDataSource(episodeFile.getAudioFilePath(episode)); mediaPlayer.setOnPreparedListener(this); mediaPlayer.prepareAsync(); return mediaPlayer; } @Inject  AudioPlayer(MediaPlayer mediaPlayer, EventBus eventBus, EpisodeFile episodeFile); MediaPlayer play(Episode episode); void release(); @Override void start(); @Override void pause(); @Override int getDuration(); @Override int getCurrentPosition(); @Override void seekTo(int pos); @Override boolean isPlaying(); @Override int getBufferPercentage(); @Override boolean canPause(); @Override boolean canSeekBackward(); @Override boolean canSeekForward(); @Override int getAudioSessionId(); @Override void onPrepared(MediaPlayer mediaPlayer);  }
@Test public void itSetsAudioStreamType() throws IOException { audioPlayer.play(episode); verify(mediaPlayerMock).setAudioStreamType(AudioManager.STREAM_MUSIC); }
@Test public void itSetsDataSourceAndPreparesMediaPlayerGivenAnEpisodeAudioPath() throws IOException { String episodeAutioPath = "audio.mp3"; when(episodeFileMock.getAudioFilePath(episode)).thenReturn(episodeAutioPath); audioPlayer.play(episode); InOrder order = inOrder(mediaPlayerMock); order.verify(mediaPlayerMock).setDataSource(episodeAutioPath); order.verify(mediaPlayerMock).prepareAsync(); }