Screen Capture
このガイドでは、MediaProjection APIを使用してRoomに接続された参加者にAndroidデバイスのアプリケーション画面を共有する方法について触れています。
If you are interested in capturing from an Android View in the View hierarchy instead of capturing from the device screen you can take a look at our custom video capturer example instead:
Using the Screen Capturer API
Video Android SDKに含まれるScreenCapturerクラスは、デバイス画面からのLocalVideoTrack用のビデオフレームを提供する用途に使用されます。 フレームはMediaProjection
APIによって提供されます。 キャプチャラーはBuild.VERSION_CODES.LOLLIPOP
以降のみに対応しています。
VideoViewを初期化する
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_screen_capturer); localVideoView = findViewById(R.id.local_video); }
Request screen capture permission from user
Get an instance of the MediaProjectionManager service. Call the createScreenCaptureIntent
method in a new activity. This initiates a prompt dialog for the user to confirm screen projection.
Request Screen Capturer Permission
private void requestScreenCapturePermission() { Log.d(TAG, "Requesting permission to capture screen"); MediaProjectionManager mediaProjectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE); // This initiates a prompt dialog for the user to confirm screen projection. startActivityForResult(mediaProjectionManager.createScreenCaptureIntent(), REQUEST_MEDIA_PROJECTION); }
Start Screen capture when permission received
ユーザーから権限を受け取ってから、ScreenCapturer
クラスを初期化します。 LocalVideoTrackオブジェクトを作成し、ScreenCapturer
オブジェクトを渡して取り込まれたローカルビデオフレームを渡します。 VideoView
オブジェクトをVisible
に設定します。 LocalVideoTrack
オブジェクトのaddRender
メソッドを呼び出します。 VideoView
オブジェクトを渡して、画面キャプチャービデオの受信を開始します。
Using the Screen Capturer Class
private void startScreenCapture() { screenVideoTrack = LocalVideoTrack.create(this, true, screenCapturer); screenCaptureMenuItem.setIcon(R.drawable.ic_stop_screen_share_white_24dp); screenCaptureMenuItem.setTitle(R.string.stop_screen_share); localVideoView.setVisibility(View.VISIBLE); screenVideoTrack.addRenderer(localVideoView); }
エラーが見つかりましたか? GithubでIssueをオープンしましょう。
どこかで行き詰まりましたか? お探しのものが見つかりませんか? お気軽に twilio_support@kddi-web.com にお問い合わせいただければ、喜んで解決のお手伝いをいたします。
ヘルプが必要ですか?
誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。