Home | History | Annotate | Download | only in playback
      1 page.title=  
      2 page.keywords=preview,sdk,PIP,Picture-in-picture
      3 page.tags=androidn
      4 
      5 @jd:body
      6 
      7 <div id="tb-wrapper">
      8 <div id="tb">
      9 
     10 <h2></h2>
     11 <ol>
     12   <li><a href="#declaring">  
     13 </a></li>
     14   <li><a href="#pip_button">  </a>
     15 </li>
     16   <li><a href="#handling_ui">   UI </a>
     17 </li>
     18   <li><a href="#continuing_playback">  
     19 </a></li>
     20   <li><a href="#single_playback">  
     21 </a></li>
     22   <li><a href="#best"> </a></li>
     23 </ol>
     24 
     25 <h2></h2>
     26 <ol>
     27   <li><a href="{@docRoot}preview/features/multi-window.html"> 
     28 </a></li>
     29 </ol>
     30 
     31 </div>
     32 </div>
     33 
     34 <p>Android N Android TV 
     35 
     36   PIP
     37 
     38 PIP 
     39 </p>
     40 
     41 <p>PIP PIP 
     42 </p>
     43 
     44 <ul>
     45 <li> PIP 
     46 </li>
     47 <li> PIP 
     48 
     49 </li>
     50 <li>
     51  PIP 
     52 </li>
     53 </ul>
     54 
     55 <p>PIP  240 x 135 dp  4 
     56  PIP PIP  [<b>Home</b>]  PIP 
     57 
     58 PIP 
     59 
     60  PIP </p>
     61 
     62 <img src="{@docRoot}images/android-7.0/pip-active.png" />
     63 <p class="img-caption"><strong> 1.</strong>   
     64 
     65 </p>
     66 
     67 <p>PIP Android N  API  
     68 PIP PIP  PIP UI  PIP 
     69 
     70 
     71 </p>
     72 
     73 <h2 id="declaring">  </h2>
     74 
     75 <p> PIP  PIP 
     76 <code>android:supportsPictureInPicture</code> 
     77 <code>android:resizeableActivity</code>  <code>true</code> 
     78 
     79 PIP 
     80 
     81 </p>
     82 
     83 <pre>
     84 &lt;activity android:name="VideoActivity"
     85     android:resizeableActivity="true"
     86     android:supportsPictureInPicture="true"
     87     android:configChanges=
     88         "screenSize|smallestScreenSize|screenLayout|orientation"
     89     ...
     90 </pre>
     91 
     92 <p>PIP  TV  
     93  UI  
     94  UI PIP  PIP  UI 
     95 
     96 
     97 </p>
     98 
     99 <h2 id="pip_button">  </h2>
    100 
    101  PIP 
    102 <code>Activity.enterPictureInPictureMode()</code>    PIP PIP 
    103 
    104 </p>
    105 
    106 <pre>
    107 &#64;Override
    108 public void onActionClicked(Action action) {
    109     if (action.getId() == R.id.lb_control_picture_in_picture) {
    110         getActivity().enterPictureInPictureMode();
    111         return;
    112     }
    113     ...
    114 </pre>
    115 
    116 <p>   PIP  PIP 
    117 </p>
    118 
    119 <img src="{@docRoot}images/android-7.0/pip-button.png" />
    120 <p class="img-caption"><strong> 1.</strong>    [Picture-in-picture] 
    121 </p>
    122 
    123 <p>Android N 
    124 <code>PlaybackControlsRow.PictureInPictureAction</code>   PIP  PIP 
    125 </p>
    126 
    127 <h2 id="handling_ui">   UI </h2>
    128 
    129 <p> PIP 
    130  PIP  UI <code>Activity.onPictureInPictureModeChanged()</code> 
    131 <code>Fragment.onPictureInPictureModeChanged()</code>  UI 
    132 
    133 
    134 </p>
    135 
    136 <pre>
    137 &#64;Override
    138 public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
    139     if (isInPictureInPictureMode) {
    140         // Hide the controls in picture-in-picture mode.
    141         ...
    142     } else {
    143         // Restore the playback UI based on the playback status.
    144         ...
    145     }
    146 }
    147 </pre>
    148 
    149 <h2 id="continuing_playback">  
    150 </h2>
    151 
    152 <p> PIP  <code>onPause()</code> 
    153 PIP 
    154 
    155 
    156 <code>onPause()</code>  PIP 
    157 </p>
    158 
    159 <pre>
    160 &#64;Override
    161 public void onPause() {
    162     // If called while in PIP mode, do not pause playback
    163     if (isInPictureInPictureMode()) {
    164         // Continue playback
    165         ...
    166     }
    167     // If paused but not in PIP, pause playback if necessary
    168     ...
    169 }
    170 </pre>
    171 
    172 <p> PIP  <code>onResume()</code> 
    173 </p>
    174 
    175 <h2 id="single_playback">  
    176 </h2>
    177 
    178 <p> PIP 
    179 
    180 
    181 </p>
    182 
    183 <p> PIP 
    184 <code>android:launchMode</code>  <code>singleTask</code> 
    185 
    186 </p>
    187 
    188 <pre>
    189 &lt;activity android:name="VideoActivity"
    190     ...
    191     android:supportsPictureInPicture="true"
    192     android:launchMode="singleTask"
    193     ...
    194 </pre>
    195 
    196 <p>{@link android.app.Activity#onNewIntent
    197 Activity.onNewIntent()} 
    198 </p>
    199 
    200 <h2 id="best"> </h2>
    201 
    202 <p>PIP  PIP  PIP <a href="#handling_ui">   UI </a>UI 
    203 
    204 
    205 </p>
    206 
    207 <p>PIP  PIP 
    208 
    209 </p>
    210 
    211 <p> PIP PIP 
    212 <code>MediaSession.setMediaButtonReceiver()</code> 
    213 </p>
    214