Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/android/AudioPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
Expand Down