File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -384,7 +384,9 @@ public void pausePlaying() {
384384 public void stopPlaying () {
385385 if ((this .state == STATE .MEDIA_RUNNING ) || (this .state == STATE .MEDIA_PAUSED )) {
386386 this .player .pause ();
387- this .player .seekTo (0 );
387+ if (this .player .getDuration () > 0 ) {
388+ this .player .seekTo (0 );
389+ }
388390 LOG .d (LOG_TAG , "stopPlaying is calling stopped" );
389391 this .setState (STATE .MEDIA_STOPPED );
390392 }
@@ -482,8 +484,12 @@ public float getDuration(String file) {
482484 public void onPrepared (MediaPlayer player ) {
483485 // Listen for playback completion
484486 this .player .setOnCompletionListener (this );
485- // seek to any location received while not prepared
486- this .seekToPlaying (this .seekOnPrepared );
487+
488+ if (this .player .getDuration () > 0 ) {
489+ // seek to any location received while not prepared
490+ this .seekToPlaying (this .seekOnPrepared );
491+ }
492+
487493 // If start playing after prepared
488494 if (!this .prepareOnly ) {
489495 this .player .start ();
You can’t perform that action at this time.
0 commit comments