0

Am using Exoplayer2 to streaming the video with hls url, Done the activity to enter in Picture-in-Picture mode while click back or click home button. I want to drag down the exoplayer view to enter in Picture-in-Picture mode or drag down the exoplayer view to Scale it like Picture-in-Picture type.

In that Video screen also have other views like details of the video. When i drag the exoplayer view, at the time of scale the exoplayer video and fade to hide the details view.

Picture-in-Picture code

private void pictureInPictureMode() {

    if (supportsPiPMode() && getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)) {

        Rational aspectRatio = new Rational(playerView.getWidth(), playerView.getHeight());
        pictureInPictureParamsBuilder.setAspectRatio(aspectRatio).build();
        if (canEnterPiPMode()) enterPictureInPictureMode(pictureInPictureParamsBuilder.build());

    }

}

@Override
public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) {
    inPIP = isInPictureInPictureMode;
    if (isInPictureInPictureMode) {
        landscapeViews();
        bottomAdv.setVisibility(View.GONE);
    } else {
        portraitViews();
    }
}

@Override
protected void onUserLeaveHint() {
    pictureInPictureMode();
}

private boolean canEnterPiPMode() {

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        AppOpsManager appOpsManager = (AppOpsManager) getSystemService(Context.APP_OPS_SERVICE);
        return (AppOpsManager.MODE_ALLOWED == appOpsManager.checkOpNoThrow(AppOpsManager.OPSTR_PICTURE_IN_PICTURE, Process.myUid(), getPackageName()));
    }

    return false;
}

public boolean supportsPiPMode() {
    return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
}

Guide me to improve my code.

Yugesh
  • 4,030
  • 9
  • 57
  • 97
  • Have you check this : https://stackoverflow.com/q/54177127/7666442 – AskNilesh Aug 30 '19 at 06:04
  • @NileshRathod i'll check, have checked those things. Have to change the Views like that. Is any possible to change in my existing code. – Yugesh Aug 30 '19 at 06:42

0 Answers0