0

@RequiresApi(api = Build.VERSION_CODES.O) @Override public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) { if (isInPictureInPictureMode) { pipReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (intent == null || !ACTION_MEDIA_CONTROL.equals(intent.getAction())) { return; }

                        // This is where we are called back from Picture-in-Picture action
                        // items.
                        final int controlType = intent.getIntExtra(EXTRA_CONTROL_TYPE, 0);
                        switch (controlType) {
                            case CONTROL_TYPE_PLAY:
                                digiPlayerView.getPlayer().setPlayWhenReady(true);
                                pUpdatePictureInPictureActions(
                                        R.drawable.exo_icon_pause, pip_mPause, CONTROL_TYPE_PAUSE, REQUEST_PAUSE);
                                pAudioFocusFox();

                                break;
                            case CONTROL_TYPE_PAUSE:
                                digiPlayerView.getPlayer().setPlayWhenReady(false);
                                pUpdatePictureInPictureActions(
                                        R.drawable.exo_icon_play, pip_mPlay, CONTROL_TYPE_PLAY, REQUEST_PLAY);
                                // pAudioFocusAbandon();
                                break;

                            case PIP_MODE_FINISH:
                                finish();
                                try {
                                    unregisterReceiver(pipReceiver);
                                    pipReceiver = null;
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                                break;
                        }
                    }
                };
        registerReceiver(pipReceiver, new IntentFilter(ACTION_MEDIA_CONTROL));
    } else {
        try {
            unregisterReceiver(pipReceiver);
            pipReceiver = null;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //here player user controls
    digiPlayerView.setUseController(!isInPictureInPictureMode);
}
4

0 回答 0