@Override public void onUserLeaveHint() { super.onUserLeaveHint(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (prefConfig.enablePip && connected) { enterPictureInPictureMode( new PictureInPictureParams.Builder() .setAspectRatio(new Rational(prefConfig.width, prefConfig.height)) .setSourceRectHint(new Rect( streamView.getLeft(), streamView.getTop(), streamView.getRight(), streamView.getBottom())) .build()); } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_pip_test); mFramePlayer = findViewById(R.id.frame_mock_player); mBtnPip = findViewById(R.id.btn_minimize); mBtnPip.setOnClickListener(view -> { if (android.os.Build.VERSION.SDK_INT >= 26) { //Trigger PiP mode try { Rational rational = new Rational(mFramePlayer.getWidth(), mFramePlayer.getHeight()); PictureInPictureParams mParams = new PictureInPictureParams.Builder() .setAspectRatio(rational) .build(); enterPictureInPictureMode(mParams); } catch (IllegalStateException e) { e.printStackTrace(); } } else { Toast.makeText(PipActivity.this, "API 26 needed to perform PiP", Toast.LENGTH_SHORT).show(); } }); }
private View.OnClickListener onPictureInPictureClick() { return view -> { if (exoPlayer != null && exoPlayer.getPlaybackState() == SimpleExoPlayer.STATE_READY) { int videoWidth = exoPlayer.getVideoFormat().width; int videoHeight = exoPlayer.getVideoFormat().height; PictureInPictureParams params = new PictureInPictureParams.Builder() .setAspectRatio(new Rational(videoWidth, videoHeight)) .build(); enterPictureInPictureMode(params); } else { Toast.makeText(PictureInPictureActivity.this, R.string.video_playback_not_ready, Toast.LENGTH_SHORT).show(); } }; }
@Override protected void onPause() { super.onPause(); if (player.getPlayWhenReady() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { PictureInPictureParams params = new PictureInPictureParams.Builder() .build(); enterPictureInPictureMode(params); } }
boolean enterPictureInPictureMode(final CallFun1<Boolean, PictureInPictureParams> superCall, final PictureInPictureParams params) { synchronized (mSuperListeners) { mSuperListeners.push(superCall); return enterPictureInPictureMode(params); } }
void setPictureInPictureParams(final CallVoid1<PictureInPictureParams> superCall, final PictureInPictureParams params) { synchronized (mSuperListeners) { mSuperListeners.push(superCall); setPictureInPictureParams(params); } }
public void onEnterIntoPIPClicked(View view) { PictureInPictureParams params = new PictureInPictureParams.Builder() .setAspectRatio(new Rational(10, 16)) // Portrait Aspect Ratio .build(); enterPictureInPictureMode(params); }
@Override public boolean enterPictureInPictureMode(final PictureInPictureParams params) { return super.enterPictureInPictureMode(params); }
@Override public void setPictureInPictureParams(final PictureInPictureParams params) { super.setPictureInPictureParams(params); }
@Override public boolean enterPictureInPictureMode(final PictureInPictureParams params) { return delegate.enterPictureInPictureMode(params); }
@Override public void setPictureInPictureParams(final PictureInPictureParams params) { delegate.setPictureInPictureParams(params); }
@Override public boolean super_enterPictureInPictureMode(final PictureInPictureParams params) { return super.enterPictureInPictureMode(params); }
@Override public void super_setPictureInPictureParams(final PictureInPictureParams params) { super.setPictureInPictureParams(params); }
public boolean enterPictureInPictureMode(final PictureInPictureParams params) { verifyMethodCalledFromDelegate("enterPictureInPictureMode(PictureInPictureParams)"); return ((CallFun1<Boolean, PictureInPictureParams>) mSuperListeners.pop()).call(params); }
public void setPictureInPictureParams(final PictureInPictureParams params) { verifyMethodCalledFromDelegate("setPictureInPictureParams(PictureInPictureParams)"); ((CallVoid1<PictureInPictureParams>) mSuperListeners.pop()).call(params); }
public void pipActivity(View view) { PictureInPictureParams params = new PictureInPictureParams.Builder() .setAspectRatio(new Rational(9,16)) // Portrait Aspect Ratio .build(); enterPictureInPictureMode(params); }
boolean enterPictureInPictureMode(final PictureInPictureParams params);
void setPictureInPictureParams(final PictureInPictureParams params);
boolean super_enterPictureInPictureMode(final PictureInPictureParams params);
void super_setPictureInPictureParams(final PictureInPictureParams params);