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 @@ -340,7 +340,9 @@ public void pausePlaying() {
340
340
public void stopPlaying () {
341
341
if ((this .state == STATE .MEDIA_RUNNING ) || (this .state == STATE .MEDIA_PAUSED )) {
342
342
this .player .pause ();
343
- this .player .seekTo (0 );
343
+ if (this .player .getDuration () > 0 ) {
344
+ this .player .seekTo (0 );
345
+ }
344
346
Log .d (LOG_TAG , "stopPlaying is calling stopped" );
345
347
this .setState (STATE .MEDIA_STOPPED );
346
348
}
@@ -431,8 +433,12 @@ public float getDuration(String file) {
431
433
public void onPrepared (MediaPlayer player ) {
432
434
// Listen for playback completion
433
435
this .player .setOnCompletionListener (this );
434
- // seek to any location received while not prepared
435
- this .seekToPlaying (this .seekOnPrepared );
436
+
437
+ if (this .player .getDuration () > 0 ) {
438
+ // seek to any location received while not prepared
439
+ this .seekToPlaying (this .seekOnPrepared );
440
+ }
441
+
436
442
// If start playing after prepared
437
443
if (!this .prepareOnly ) {
438
444
this .player .start ();
You can’t perform that action at this time.
0 commit comments