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() {
384
384
public void stopPlaying () {
385
385
if ((this .state == STATE .MEDIA_RUNNING ) || (this .state == STATE .MEDIA_PAUSED )) {
386
386
this .player .pause ();
387
- this .player .seekTo (0 );
387
+ if (this .player .getDuration () > 0 ) {
388
+ this .player .seekTo (0 );
389
+ }
388
390
LOG .d (LOG_TAG , "stopPlaying is calling stopped" );
389
391
this .setState (STATE .MEDIA_STOPPED );
390
392
}
@@ -482,8 +484,12 @@ public float getDuration(String file) {
482
484
public void onPrepared (MediaPlayer player ) {
483
485
// Listen for playback completion
484
486
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
+
487
493
// If start playing after prepared
488
494
if (!this .prepareOnly ) {
489
495
this .player .start ();
You can’t perform that action at this time.
0 commit comments