Created
October 14, 2022 06:57
-
-
Save tfaki/fd74617d310188039df8c6eb2ce78611 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun pictureInPictureMode(){ | |
//Requires Android O and higher | |
Log.d(TAG, "pictureInPictureMode: Try to enter in PIP mode") | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){ | |
Log.d(TAG, "pictureInPictureMode: Supports PIP") | |
//setup PIP height width | |
val aspectRatio = Rational(videoView.width, videoView.height) | |
pictureInPictureParamsBuilder!!.setAspectRatio(aspectRatio).build() | |
enterPictureInPictureMode(pictureInPictureParamsBuilder!!.build()) | |
} | |
else{ | |
Log.d(TAG, "pictureInPictureMode: Doesn't supports PIP") | |
Toast.makeText(this, "Your device doesn't supports PIP", Toast.LENGTH_LONG).show() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment