81.3 Entering Picture-in-Picture Mode
The enterPipMode onClick callback method now needs to be added to the MainActivity.kt class file. Locate this file, open it in the code editor and add this method as follows:
.
.
import android.app.PictureInPictureParams
import android.util.Rational
import android.view.View
import android.content.res.Configuration
.
.
fun enterPipMode(view: View) {
val rational = Rational(videoView1.width,
videoView1.height)
val params = PictureInPictureParams.Builder()
.setAspectRatio(rational)
.build()
pipButton.visibility = View.INVISIBLE
videoView1.setMediaController(null)
...