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