Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c5d9c8f1 authored by Daniel Yu's avatar Daniel Yu
Browse files

docs: Adding section about single task activity for playback with PIP

Adding a new section to the N Preview PIP docs that emphasize using
a single playback activity for video. Information provided from
developer gdoc.

See CL comments for staged preview URL.

Bug: 27745102

Change-Id: Ic310c0b1882bac7256e2bad5a5cd33a7d9b849fa
parent 098de48e
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@ Picture-in-picture</a></li>
  <li><a href="#handling_ui">Handling UI During Picture-in-picture</a>
</li>
  <li><a href="#continuing_playback">Continuing Video Playback While in
Picture-in-picture</a></li>
  <li><a href="#single_playback">Using a Single Playback Activity for
Picture-in-picture</a></li>
  <li><a href="#best">Best Practices</a></li>
</ol>
@@ -170,6 +172,31 @@ public void onPause() {
<p>When your activity switches out of PIP mode back to full-screen mode, the
system resumes your activity and calls your <code>onResume()</code> method.</p>

<h2 id="single_playback">Using a Single Playback Activity for
Picture-in-picture</h2>

<p>In your app, a user might select a new video when browsing for content on
the main screen, while a video playback activity is in PIP mode. Play the new
video in the existing playback activity in full screen mode, instead of
launching a new activity that might confuse the user.</p>

<p>To ensure a single activity is used for video playback requests and
switched into or out of PIP mode as needed, set the activity's
<code>android:launchMode</code> to <code>singleTask</code> in your manifest:
</p>

<pre>
&lt;activity android:name="VideoActivity"
    ...
    android:supportsPictureInPicture="true"
    android:launchMode="singleTask"
    ...
</pre>

<p>In your activity, override {@link android.app.Activity#onNewIntent
Activity.onNewIntent()} and handle the new video, stopping any existing video
playback if needed.</p>

<h2 id="best">Best Practices</h2>

<p>PIP is intended for activities that play full-screen video. When switching