diff --git a/src/android/AudioPlayer.java b/src/android/AudioPlayer.java index b40e281e..ddbf92b5 100644 --- a/src/android/AudioPlayer.java +++ b/src/android/AudioPlayer.java @@ -384,7 +384,9 @@ public void pausePlaying() { public void stopPlaying() { if ((this.state == STATE.MEDIA_RUNNING) || (this.state == STATE.MEDIA_PAUSED)) { this.player.pause(); - this.player.seekTo(0); + if (this.player.getDuration() > 0) { + this.player.seekTo(0); + } LOG.d(LOG_TAG, "stopPlaying is calling stopped"); this.setState(STATE.MEDIA_STOPPED); } @@ -482,8 +484,12 @@ public float getDuration(String file) { public void onPrepared(MediaPlayer player) { // Listen for playback completion this.player.setOnCompletionListener(this); - // seek to any location received while not prepared - this.seekToPlaying(this.seekOnPrepared); + + if (this.player.getDuration() > 0) { + // seek to any location received while not prepared + this.seekToPlaying(this.seekOnPrepared); + } + // If start playing after prepared if (!this.prepareOnly) { this.player.start();