Kotlin
ピクチャー・イン・ピクチャーの起動
1.ピクチャー・イン・ピクチャーに入るためのボタンを追加する
PiP中にボタンを隠す。からの配線 VideoCallScreen:
if (!isInPipMode) {
Button(
onClick = onEnterPictureInPicture,
modifier = Modifier.align(Alignment.TopStart).padding(8.dp),
) {
Text("Enter Picture-In-Picture")
}
}
2.アスペクト比とデバイス チェックで PiP を入力する
用途 PictureInPictureParams をAPI 26+で実行し、デバイスがPiPをサポートしていることを確認してください:
private fun enterPictureInPicture() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
Toast.makeText(this, "Picture-in-picture is not supported on this device.", Toast.LENGTH_SHORT)
.show()
return
}
if (!packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)) {
Toast.makeText(this, "Picture-in-picture is not supported on this device.", Toast.LENGTH_SHORT)
.show()
return
}
try {
val params = PictureInPictureParams.Builder()
.setAspectRatio(Rational(9, 16))
.build()
enterPictureInPictureMode(params)
} catch (e: IllegalStateException) {
Log.e(TAG, "Failed to enter picture-in-picture mode", e)
Toast.makeText(this, "Could not enter picture-in-picture mode.", Toast.LENGTH_SHORT).show()
}
}
調整 Rational(width, height) を選択して、お好みの PiP ウィンドウの形状に合わせます (サンプルではポートレート 9:16 を使用しています)。
ピクチャー・イン・ピクチャー
Vonage Video SDKを使用してアプリにPicture in Picture機能を追加する方法をご紹介します。
以下の言語で利用可能:
手順
1
はじめに2
はじめに3
新規プロジェクトの作成4
Android SDKの追加5
認証の設定6
アクセス許可の申請7
アクティビティでピクチャー・イン・ピクチャーを有効にする8
動画視聴用のコンテナを提供する9
ピクチャー・イン・ピクチャーの起動10
PiP モードの変更を管理する11
アプリの実行12
結論