private void h()
 {
   if (!B.p())
   {
     l.e(k, "changeToCastMode error, chromecast is not connected");
     return;
   }
   if (p != null) {
     p.hide();
   }
   m();
   A = 1;
   o.setVisibility(0);
   if (q == null)
   {
     q = new kk(this, this);
     if (r == null)
     {
       r = new kt(this);
       B.a(r);
       B.a(r);
       B.a(r);
     }
     q.setMediaPlayer(r);
     q.setAnchorView(o);
   }
   ((ImageView)z.findViewById(2131624054)).setImageResource(2130838531);
   if ((B.r() > 0) && (B.r() != 2)) {
     b.setVisibility(0);
   }
   J.sendMessageDelayed(J.obtainMessage(5), 1000L);
 }
Example #2
0
 @Override
 public void hide() {
   if (mVideoView != null) {
     mVideoView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
   }
   mMediaController.hide();
 }
  @Override
  public boolean dispatchKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    if (event.getRepeatCount() == 0
        && event.isDown()
        && (keyCode == KeyEvent.KEYCODE_HEADSETHOOK
            || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
            || keyCode == KeyEvent.KEYCODE_SPACE)) {
      doPauseResume();
      show(sDefaultTimeout);
      if (mPauseButton != null) {
        mPauseButton.requestFocus();
      }
      return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP) {
      if (mPlayer.isPlaying()) {
        mPlayer.pause();
        updatePausePlay();
      }
      return true;
    } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
      // don't show the controls for volume adjustment
      return super.dispatchKeyEvent(event);
    } else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) {
      hide();

      return true;
    } else {
      show(sDefaultTimeout);
    }
    return super.dispatchKeyEvent(event);
  }
Example #4
0
 @Override
 protected void onStop() {
   super.onStop();
   mediaController.hide();
   mediaPlayer.stop();
   mediaPlayer.release();
 }
Example #5
0
 public void setMediaController(MediaController controller) {
   if (mMediaController != null) {
     mMediaController.hide();
   }
   mMediaController = controller;
   attachMediaController();
 }
Example #6
0
 private void toggleMediaControlsVisiblity() {
   if (mMediaController.isShowing()) {
     mMediaController.hide();
   } else {
     mMediaController.show();
   }
 }
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (mIsPrepared
        && keyCode != KeyEvent.KEYCODE_BACK
        && keyCode != KeyEvent.KEYCODE_VOLUME_UP
        && keyCode != KeyEvent.KEYCODE_VOLUME_DOWN
        && keyCode != KeyEvent.KEYCODE_MENU
        && keyCode != KeyEvent.KEYCODE_CALL
        && keyCode != KeyEvent.KEYCODE_ENDCALL
        && mMediaPlayer != null
        && mMediaController != null) {
      if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
        if (mMediaPlayer.isPlaying()) {
          pause();
          mMediaController.show();
        } else {
          start();
          mMediaController.hide();
        }
        return true;
      } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP && mMediaPlayer.isPlaying()) {
        pause();
        mMediaController.show();
      } else {
        toggleMediaControlsVisiblity();
      }
    }

    return super.onKeyDown(keyCode, event);
  }
  public void siguienteCancion() {
    if (!server.finJuego()) {
      new ProgressTask<Canciones>(this) {
        @Override
        protected Canciones work() throws Exception {
          cancion = server.getCanciones();
          return cancion;
        }

        @Override
        protected void onFinish(Canciones cancion) {
          tituloView.setText(cancion.getTitulo());
          String urlCancion = cancion.getVideo();
          playVideo(urlCancion);
        }
      }.execute();
    } else {
      LinearLayout layoutEntero = (LinearLayout) findViewById(R.id.layout_canciones_entero);
      layoutEntero.removeAllViews();
      controller.hide();
      TextView txNuevo = new TextView(this);
      txNuevo.setText("AMAIERA");
      txNuevo.setTextColor(Color.WHITE);
      txNuevo.setGravity(Gravity.CENTER);
      txNuevo.setTextSize(70);
      layoutEntero.addView(txNuevo);
    }
  }
 public boolean onTouch(View v, MotionEvent event) {
   if (event.getAction() == MotionEvent.ACTION_DOWN) {
     if (mShowing) {
       hide();
     }
   }
   return false;
 }
 private void toggleControlsVisibility() {
   if (mediaController.isShowing()) {
     mediaController.hide();
     // debugRootView.setVisibility(View.GONE);
   } else {
     showControls();
   }
 }
Example #11
0
 public void onCompletion(MediaPlayer mp) {
   if (mMediaController != null) {
     mMediaController.hide();
   }
   if (mOnCompletionListener != null) {
     mOnCompletionListener.onCompletion(mMediaPlayer);
   }
 }
Example #12
0
        public boolean onError(MediaPlayer mp, int framework_err, int impl_err) {
          Log.d(TAG, "Error: " + framework_err + "," + impl_err);
          mCurrentState = STATE_ERROR;
          mTargetState = STATE_ERROR;
          if (mMediaController != null) {
            mMediaController.hide();
          }

          /* If an error handler has been supplied, use it and finish. */
          if (mOnErrorListener != null) {
            if (mOnErrorListener.onError(mMediaPlayer, framework_err, impl_err)) {
              return true;
            }
          }

          /* Otherwise, pop up an error dialog so the user knows that
           * something bad has happened. Only try and pop up the dialog
           * if we're attached to a window. When we're going away and no
           * longer have a window, don't bother showing the user an error.
           */
          // modify by lxj
          //            if (getWindowToken() != null) {
          //                Resources r = mContext.getResources();
          //                int messageId;
          //
          //                if (framework_err ==
          // MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK) {
          //                    messageId =
          // com.android.internal.R.string.VideoView_error_text_invalid_progressive_playback;
          //                } else {
          //                    messageId =
          // com.android.internal.R.string.VideoView_error_text_unknown;
          //                }
          //
          //                new AlertDialog.Builder(mContext)
          //                        .setMessage(messageId)
          //
          // .setPositiveButton(com.android.internal.R.string.VideoView_error_button,
          //                                new DialogInterface.OnClickListener() {
          //                                    public void onClick(DialogInterface dialog, int
          // whichButton) {
          //                                        /* If we get here, there is no onError listener,
          // so
          //                                         * at least inform them that the video is over.
          //                                         */
          //                                        if (mOnCompletionListener != null) {
          //
          // mOnCompletionListener.onCompletion(mMediaPlayer);
          //                                        }
          //                                    }
          //                                })
          //                        .setCancelable(false)
          //                        .show();
          //            }
          return true;
        }
 public void surfaceDestroyed(SurfaceHolder holder) {
   // after we return from this we can't use the surface any more
   mSurfaceHolder = null;
   if (mMediaController != null) mMediaController.hide();
   if (mMediaPlayer != null) {
     mMediaPlayer.reset();
     mMediaPlayer.release();
     mMediaPlayer = null;
   }
 }
Example #14
0
 public void onCompletion(MediaPlayer mp) {
   mCurrentState = STATE_PLAYBACK_COMPLETED;
   mTargetState = STATE_PLAYBACK_COMPLETED;
   if (mMediaController != null) {
     mMediaController.hide();
   }
   if (mOnCompletionListener != null) {
     mOnCompletionListener.onCompletion(mMediaPlayer);
   }
 }
 @Override
 public void onStop() {
   super.onStop();
   if (mMenu != null) {
     mMenu.removeItem(R.id.action_share);
     mMenu.removeItem(R.id.action_favorite);
     mMenu.removeItem(R.id.action_unfavorite);
     mMenu = null;
   }
   if (mMediaController != null && mMediaController.isShowing()) {
     mMediaController.hide();
   }
 }
        public boolean onError(MediaPlayer mp, int framework_err, int impl_err) {
          Log.d(TAG, "Error: " + framework_err + "," + impl_err);
          if (mMediaController != null) {
            mMediaController.hide();
          }

          /* If an error handler has been supplied, use it and finish. */
          if (mOnErrorListener != null) {
            if (mOnErrorListener.onError(mMediaPlayer, framework_err, impl_err)) {
              return true;
            }
          }

          /* Otherwise, pop up an error dialog so the user knows that
           * something bad has happened. Only try and pop up the dialog
           * if we're attached to a window. When we're going away and no
           * longer have a window, don't bother showing the user an error.
           */
          if (getWindowToken() != null) {
            Resources r = getContext().getResources();
            String message;

            if (framework_err == MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK) {
              message = "Invalid Progressive Playback";
              // messageId =
              // com.android.internal.R.string.VideoView_error_text_invalid_progressive_playback;
            } else {
              message = "Unknown error";
              // messageId = com.android.internal.R.string.VideoView_error_text_unknown;
            }

            new AlertDialog.Builder(getContext())
                .setTitle("Video View")
                .setMessage(message)
                .setPositiveButton(
                    "Error",
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int whichButton) {
                        /* If we get here, there is no onError listener, so
                         * at least inform them that the video is over.
                         */
                        if (mOnCompletionListener != null) {
                          mOnCompletionListener.onCompletion(mMediaPlayer);
                        }
                      }
                    })
                .setCancelable(false)
                .show();
          }
          return true;
        }
 public void invalidateView() {
   final boolean show = controller != null && controller.isShowing();
   if (DEBUG) {
     Log.d(TAG, "Invalidate view, controller showing: " + show);
   }
   if (show) {
     controller.hide();
     // XXX don't know when we have new dimensions, it should be done with something like
     // requestLayout
     final long delay = 250;
     handler.removeCallbacks(showController);
     handler.postDelayed(showController, delay);
   }
 }
Example #18
0
 @Override
 // POINT: 컨트롤러를 다시 보여 준다.
 public boolean onTouchEvent(MotionEvent ev) {
   if (ev.getAction() == MotionEvent.ACTION_DOWN) {
     if (controller.isShowing()) {
       controller.hide();
       // surfaceView.setLayoutParams(new FrameLayout.LayoutParams(
       // videoWidth, videoHeight));
     } else {
       controller.show();
       // surfaceView.setLayoutParams(new FrameLayout.LayoutParams(
       // videoWidth, videoHeight - 75));
     }
   }
   return false;
 }
 private void k()
 {
   A = 0;
   if (q != null) {
     q.hide();
   }
   o.setVisibility(8);
   Message localMessage = J.obtainMessage(4);
   J.sendMessageDelayed(localMessage, 100L);
   o();
   ((ImageView)z.findViewById(2131624054)).setImageResource(2130838530);
   if (b.getVisibility() == 0) {
     b.setVisibility(8);
   }
   J.removeMessages(5);
 }
 @Override
 public void handleMessage(Message msg) {
   int pos;
   switch (msg.what) {
     case FADE_OUT:
       hide();
       break;
     case SHOW_PROGRESS:
       pos = setProgress();
       if (!mDragging && mShowing && mPlayer.isPlaying()) {
         msg = obtainMessage(SHOW_PROGRESS);
         sendMessageDelayed(msg, 1000 - (pos % 1000));
       }
       break;
   }
 }
 @Override
 public boolean onTouchEvent(MotionEvent event) {
   switch (event.getAction()) {
     case MotionEvent.ACTION_DOWN:
       show(0); // show until hide is called
       break;
     case MotionEvent.ACTION_UP:
       show(sDefaultTimeout); // start timeout
       break;
     case MotionEvent.ACTION_CANCEL:
       hide();
       break;
     default:
       break;
   }
   return true;
 }
  @Override
  public boolean dispatchKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    final boolean uniqueDown =
        event.getRepeatCount() == 0 && event.getAction() == KeyEvent.ACTION_DOWN;
    if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK
        || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
        || keyCode == KeyEvent.KEYCODE_SPACE) {
      if (uniqueDown) {
        doPauseResume();
        show(sDefaultTimeout);
        if (mPauseButton != null) {
          mPauseButton.requestFocus();
        }
      }
      return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
      if (uniqueDown && !mPlayer.isPlaying()) {
        mPlayer.start();
        updatePausePlay();
        show(sDefaultTimeout);
      }
      return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
      if (uniqueDown && mPlayer.isPlaying()) {
        mPlayer.pause();
        updatePausePlay();
        show(sDefaultTimeout);
      }
      return true;
    } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
        || keyCode == KeyEvent.KEYCODE_VOLUME_UP
        || keyCode == KeyEvent.KEYCODE_VOLUME_MUTE
        || keyCode == KeyEvent.KEYCODE_CAMERA) {
      // don't show the controls for volume adjustment
      return super.dispatchKeyEvent(event);
    } else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) {
      if (uniqueDown) {
        hide();
      }
      return true;
    }

    show(sDefaultTimeout);
    return super.dispatchKeyEvent(event);
  }
Example #23
0
        public boolean onError(MediaPlayer mp, int framework_err, int impl_err) {
          Log.d(TAG, "Error: " + framework_err + "," + impl_err);
          mCurrentState = STATE_ERROR;
          mTargetState = STATE_ERROR;
          if (mMediaController != null) {
            mMediaController.hide();
          }

          /* If an error handler has been supplied, use it and finish. */
          if (mOnErrorListener != null) {
            if (mOnErrorListener.onError(mMediaPlayer, framework_err, impl_err)) {
              return true;
            }

            mOnErrorListener = null;
          }

          /* Otherwise, pop up an error dialog so the user knows that
           * something bad has happened. Only try and pop up the dialog
           * if we're attached to a window. When we're going away and no
           * longer have a window, don't bother showing the user an error.
           */
          if (getWindowToken() != null) {
            mMediaPlayer.setOnErrorListener(null);

            new AlertDialog.Builder(getContext())
                .setTitle(R.string.error_generic)
                .setMessage(R.string.loading_image_error)
                .setPositiveButton(
                    R.string.cancel,
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int whichButton) {
                        /* If we get here, there is no onError listener, so
                         * at least inform them that the video is over.
                         */
                        if (mOnCompletionListener != null) {
                          mOnCompletionListener.onCompletion(mMediaPlayer);
                        }
                      }
                    })
                .setCancelable(false)
                .show();
          }
          return true;
        }
Example #24
0
        public boolean onError(MediaPlayer mp, int a, int b) {
          Log.d("VideoView", "Error: " + a + "," + b);
          if (mMediaController != null) {
            mMediaController.hide();
          }

          /* If an error handler has been supplied, use it and finish. */
          if (mOnErrorListener != null) {
            if (mOnErrorListener.onError(mMediaPlayer, a, b)) {
              return true;
            }
          }

          /* Otherwise, pop up an error dialog so the user knows that
           * something bad has happened. Only try and pop up the dialog
           * if we're attached to a window. When we're going away and no
           * longer have a window, don't bother showing the user an error.
           */
          if (getWindowToken() != null) {
            Resources r = mContext.getResources();
            new AlertDialog.Builder(mContext)
                // .setTitle(com.android.internal.R.string.VideoView_error_title)
                // .setMessage(com.android.internal.R.string.VideoView_error_text_unknown)
                // .setPositiveButton(com.android.internal.R.string.VideoView_error_button,
                .setTitle("Video Error")
                .setMessage("Video Error unknown")
                .setPositiveButton(
                    "Positive",
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int whichButton) {
                        /* If we get here, there is no onError listener, so
                         * at least inform them that the video is over.
                         */
                        if (mOnCompletionListener != null) {
                          mOnCompletionListener.onCompletion(mMediaPlayer);
                        }
                      }
                    })
                .setCancelable(false)
                .show();
          }
          return true;
        }
 @Override
 public boolean dispatchKeyEvent(KeyEvent event) {
   int keyCode = event.getKeyCode();
   if (event.getRepeatCount() == 0
       && event.isDown()
       && (keyCode == KeyEvent.KEYCODE_HEADSETHOOK
           || keyCode == KeyEvent.KEYCODE_PLAYPAUSE
           || keyCode == KeyEvent.KEYCODE_SPACE)) {
     doPauseResume();
     show(sDefaultTimeout);
     return true;
   } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
     // don't show the controls for volume adjustment
     return super.dispatchKeyEvent(event);
   } else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) {
     hide();
   } else {
     show(sDefaultTimeout);
   }
   return super.dispatchKeyEvent(event);
 }
 public void onConfigurationChanged(Configuration paramConfiguration)
 {
   super.onConfigurationChanged(paramConfiguration);
   p.hide();
 }