@@ -328,6 +328,10 @@ private void attachMediaController() {
328328 (View )this .getParent () : this ;
329329 mMediaController .setAnchorView (anchorView );
330330 mMediaController .setEnabled (isInPlaybackState ());
331+
332+ // PM-2015-10-19: [[ Bug 16027 ]] Make sure the controller shows/hides when changing its visibility on demand
333+ if (isInPlaybackState ())
334+ mMediaController .show (0 );
331335 }
332336 }
333337
@@ -369,7 +373,13 @@ public void onPrepared(MediaPlayer mp) {
369373 }
370374 if (mMediaController != null ) {
371375 mMediaController .setEnabled (true );
376+
377+ // PM-2015-10-19: [[ Bug 16027 ]] Show the controller once the player is prepared (as on iOS)
378+ if (isInPlaybackState ()){
379+ mMediaController .show (0 );
380+ }
372381 }
382+
373383 mVideoWidth = mp .getVideoWidth ();
374384 mVideoHeight = mp .getVideoHeight ();
375385
@@ -390,10 +400,6 @@ public void onPrepared(MediaPlayer mp) {
390400 // start the video here instead of in the callback.
391401 if (mTargetState == STATE_PLAYING ) {
392402 start ();
393- if (mMediaController != null ) {
394- // PM-2015-10-08: [[ Bug 16027 ]] Make sure the controller does not disappear after some ms of inactivity
395- mMediaController .show (0 );
396- }
397403 } else if (!isPlaying () &&
398404 (seekToPosition != 0 || getCurrentPosition () > 0 )) {
399405 if (mMediaController != null ) {
@@ -407,10 +413,6 @@ public void onPrepared(MediaPlayer mp) {
407413 // The video size might be reported to us later.
408414 if (mTargetState == STATE_PLAYING ) {
409415 start ();
410- // show the controller when starting playing a remote video
411- if (mMediaController != null ) {
412- mMediaController .show (0 );
413- }
414416 }
415417 }
416418 }
@@ -542,10 +544,7 @@ public void surfaceChanged(SurfaceHolder holder, int format,
542544 seekTo (mSeekWhenPrepared );
543545 }
544546 start ();
545- if (mMediaController != null ) {
546- mMediaController .show (0 );
547- }
548- }
547+ }
549548 }
550549
551550 public void surfaceCreated (SurfaceHolder holder )
@@ -626,7 +625,7 @@ public boolean onKeyDown(int keyCode, KeyEvent event)
626625 keyCode == KeyEvent .KEYCODE_MEDIA_PLAY_PAUSE ) {
627626 if (mMediaPlayer .isPlaying ()) {
628627 pause ();
629- mMediaController .show (0 );
628+ mMediaController .show (0 );
630629 } else {
631630 start ();
632631 mMediaController .hide ();
@@ -635,7 +634,7 @@ public boolean onKeyDown(int keyCode, KeyEvent event)
635634 } else if (keyCode == KeyEvent .KEYCODE_MEDIA_STOP
636635 && mMediaPlayer .isPlaying ()) {
637636 pause ();
638- mMediaController .show (0 );
637+ mMediaController .show (0 );
639638 } else {
640639 toggleMediaControlsVisiblity ();
641640 }
@@ -659,6 +658,12 @@ public void start() {
659658 mCurrentState = STATE_PLAYING ;
660659 }
661660 mTargetState = STATE_PLAYING ;
661+
662+ // PM-2015-10-19: [[ Bug 16027 ]] Show the controller here, to make sure it is enabled even if
663+ // mobileControlDo sPlayerId, "play" is called from a callback message
664+ if (mMediaController != null ) {
665+ mMediaController .show (0 );
666+ }
662667 }
663668
664669 public void stop () {
0 commit comments