Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into jz-fill-my-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
space-pope committed Sep 25, 2020
2 parents b27e0d3 + ba4202b commit 9441ebe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,12 @@ MediaSource createMediaSource(Uri audioUri) {
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == Player.STATE_ENDED) {
resetPlayerState();
dispatch(new TTSEvent(TTSEvent.Type.PLAYBACK_COMPLETE));
// check for content produced by the TTS system; the player can
// also receive state change events for audio from another source
if (this.playerState.hasContent) {
dispatch(new TTSEvent(TTSEvent.Type.PLAYBACK_COMPLETE));
resetPlayerState();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ public void testPlayerStateChange() {

ttsOutput.onPlayerStateChanged(false, Player.STATE_ENDED);
assertFalse(ttsOutput.getPlayerState().hasContent);
// no playback_complete event if the player didn't have content from
// the TTS system
assertTrue(listener.events.isEmpty());

// now give it audio to play and check again
ttsOutput.audioReceived(new AudioResponse(Uri.EMPTY));
ttsOutput.onPlayerStateChanged(false, Player.STATE_ENDED);
assertEquals(1, listener.events.size());
assertEquals(TTSEvent.Type.PLAYBACK_COMPLETE,
listener.events.get(0).type);
Expand Down

0 comments on commit 9441ebe

Please sign in to comment.