@@ -122,6 +122,8 @@ public void run () {
122122
123123 VideoSizeListener sizeListener ;
124124 CompletionListener completionListener ;
125+
126+ private boolean currentLooping = false ;
125127 private float currentVolume = 1.0f ;
126128
127129 /** Used for sending mediaplayer tasks to the Main Looper */
@@ -182,6 +184,8 @@ public void run () {
182184 fbo = new FrameBuffer (Pixmap .Format .RGB888 , player .getVideoWidth (), player .getVideoHeight (), false );
183185 }
184186 prepared = true ;
187+ player .setVolume (currentVolume , currentVolume );
188+ player .setLooping (currentLooping );
185189 if (playRequested ) {
186190 player .start ();
187191 }
@@ -299,7 +303,7 @@ public boolean isBuffered () {
299303
300304 @ Override
301305 public void stop () {
302- if (player != null && player . isPlaying ()) {
306+ if (player != null && isPlaying ()) {
303307 player .stop ();
304308 player .reset ();
305309 }
@@ -315,7 +319,7 @@ public void onFrameAvailable (SurfaceTexture surfaceTexture) {
315319 @ Override
316320 public void pause () {
317321 // If it is running
318- if (prepared ) {
322+ if (isPlaying () ) {
319323 player .pause ();
320324 }
321325 playRequested = false ;
@@ -364,23 +368,34 @@ public void setOnCompletionListener (CompletionListener listener) {
364368
365369 @ Override
366370 public int getVideoWidth () {
371+ if (!prepared ) {
372+ return 0 ;
373+ }
367374 return player .getVideoWidth ();
368375 }
369376
370377 @ Override
371378 public int getVideoHeight () {
379+ if (!prepared ) {
380+ return 0 ;
381+ }
372382 return player .getVideoHeight ();
373383 }
374384
375385 @ Override
376386 public boolean isPlaying () {
387+ if (!prepared ) {
388+ return false ;
389+ }
377390 return player .isPlaying ();
378391 }
379392
380393 @ Override
381394 public void setVolume (float volume ) {
382395 currentVolume = volume ;
383- player .setVolume (volume , volume );
396+ if (prepared ) {
397+ player .setVolume (volume , volume );
398+ }
384399 }
385400
386401 @ Override
@@ -390,16 +405,22 @@ public float getVolume () {
390405
391406 @ Override
392407 public void setLooping (boolean looping ) {
393- player .setLooping (looping );
408+ currentLooping = looping ;
409+ if (prepared ) {
410+ player .setLooping (looping );
411+ }
394412 }
395413
396414 @ Override
397415 public boolean isLooping () {
398- return player . isLooping () ;
416+ return currentLooping ;
399417 }
400418
401419 @ Override
402420 public int getCurrentTimestamp () {
421+ if (!prepared ) {
422+ return 0 ;
423+ }
403424 return player .getCurrentPosition ();
404425 }
405426}
0 commit comments