10a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia/* 20a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Copyright 2017 The Android Open Source Project 30a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 40a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Licensed under the Apache License, Version 2.0 (the "License"); 50a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * you may not use this file except in compliance with the License. 60a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * You may obtain a copy of the License at 70a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 80a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * http://www.apache.org/licenses/LICENSE-2.0 90a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 100a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Unless required by applicable law or agreed to in writing, software 110a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * distributed under the License is distributed on an "AS IS" BASIS, 120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * See the License for the specific language governing permissions and 140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * limitations under the License. 150a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 160a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jiapackage android.media; 180a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 190a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jiaimport android.annotation.CallbackExecutor; 200a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jiaimport android.annotation.IntDef; 210a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jiaimport android.annotation.NonNull; 220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jiaimport android.annotation.Nullable; 230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jiaimport android.content.Context; 240a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jiaimport android.graphics.SurfaceTexture; 251789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jiaimport android.net.Uri; 261789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jiaimport android.os.Handler; 271789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jiaimport android.os.Parcel; 281789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jiaimport android.os.PersistableBundle; 291789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jiaimport android.view.Surface; 301789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jiaimport android.view.SurfaceHolder; 310a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 320a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jiaimport java.io.FileDescriptor; 330a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jiaimport java.io.IOException; 340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jiaimport java.io.InputStream; 350a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jiaimport java.lang.annotation.Retention; 360a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jiaimport java.lang.annotation.RetentionPolicy; 373164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shihimport java.util.ArrayList; 380a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jiaimport java.util.List; 390a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jiaimport java.util.Map; 400a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jiaimport java.util.Set; 410a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jiaimport java.util.UUID; 4247cab8322a01edee503f10e9d5cbec2a5b5cffc3Dongwon Kangimport java.util.concurrent.Executor; 430a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 440a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 450a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia/** 463a582e73c115e693bab8cb6f213d275704b9c5d7Jean-Michel Trivi * @hide 470a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * MediaPlayer2 class can be used to control playback 480a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * of audio/video files and streams. An example on how to use the methods in 490a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * this class can be found in {@link android.widget.VideoView}. 500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 510a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p>Topics covered here are: 520a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <ol> 530a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li><a href="#StateDiagram">State Diagram</a> 540a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li><a href="#Valid_and_Invalid_States">Valid and Invalid States</a> 550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li><a href="#Permissions">Permissions</a> 560a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li><a href="#Callbacks">Register informational and error callbacks</a> 570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </ol> 580a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 590a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <div class="special reference"> 600a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <h3>Developer Guides</h3> 610a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p>For more information about how to use MediaPlayer2, read the 620a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <a href="{@docRoot}guide/topics/media/mediaplayer.html">Media Playback</a> developer guide.</p> 630a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </div> 640a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 650a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <a name="StateDiagram"></a> 660a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <h3>State Diagram</h3> 670a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p>Playback control of audio/video files and streams is managed as a state 690a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * machine. The following diagram shows the life cycle and the states of a 700a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * MediaPlayer2 object driven by the supported playback control operations. 710a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The ovals represent the states a MediaPlayer2 object may reside 720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * in. The arcs represent the playback control operations that drive the object 730a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * state transition. There are two types of arcs. The arcs with a single arrow 740a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * head represent synchronous method calls, while those with 750a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * a double arrow head represent asynchronous method calls.</p> 760a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 770a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p><img src="../../../images/mediaplayer_state_diagram.gif" 780a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * alt="MediaPlayer State diagram" 790a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * border="0" /></p> 800a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 810a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p>From this state diagram, one can see that a MediaPlayer2 object has the 820a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * following states:</p> 830a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <ul> 841789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * <li>When a MediaPlayer2 object is just created using <code>create</code> or 850a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * after {@link #reset()} is called, it is in the <em>Idle</em> state; and after 860a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link #close()} is called, it is in the <em>End</em> state. Between these 870a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * two states is the life cycle of the MediaPlayer2 object. 880a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <ul> 8963f793f0f3e815c3a4895be7b02941d27d54159cWei Jia * <li> It is a programming error to invoke methods such 900a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * as {@link #getCurrentPosition()}, 910a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link #getDuration()}, {@link #getVideoHeight()}, 920a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link #getVideoWidth()}, {@link #setAudioAttributes(AudioAttributes)}, 931789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@link #setPlayerVolume(float)}, {@link #pause()}, {@link #play()}, 940a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link #seekTo(long, int)} or 951789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@link #prepare()} in the <em>Idle</em> state. 960a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>It is also recommended that once 970a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * a MediaPlayer2 object is no longer being used, call {@link #close()} immediately 980a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * so that resources used by the internal player engine associated with the 990a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * MediaPlayer2 object can be released immediately. Resource may include 1000a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * singleton resources such as hardware acceleration components and 1010a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * failure to call {@link #close()} may cause subsequent instances of 1020a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * MediaPlayer2 objects to fallback to software implementations or fail 1030a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * altogether. Once the MediaPlayer2 1040a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * object is in the <em>End</em> state, it can no longer be used and 1050a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * there is no way to bring it back to any other state. </li> 1060a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>Furthermore, 1070a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the MediaPlayer2 objects created using <code>new</code> is in the 1080a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <em>Idle</em> state. 1090a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </li> 1100a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </ul> 1110a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </li> 1120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>In general, some playback control operation may fail due to various 1130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * reasons, such as unsupported audio/video format, poorly interleaved 1140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * audio/video, resolution too high, streaming timeout, and the like. 1150a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Thus, error reporting and recovery is an important concern under 1160a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * these circumstances. Sometimes, due to programming errors, invoking a playback 1170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * control operation in an invalid state may also occur. Under all these 1180a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * error conditions, the internal player engine invokes a user supplied 1191789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * MediaPlayer2EventCallback.onError() method if an MediaPlayer2EventCallback has been 1200a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * registered beforehand via 1211789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@link #setMediaPlayer2EventCallback(Executor, MediaPlayer2EventCallback)}. 1220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <ul> 1230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>It is important to note that once an error occurs, the 1240a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * MediaPlayer2 object enters the <em>Error</em> state (except as noted 1250a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * above), even if an error listener has not been registered by the application.</li> 1260a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>In order to reuse a MediaPlayer2 object that is in the <em> 1270a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Error</em> state and recover from the error, 1280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link #reset()} can be called to restore the object to its <em>Idle</em> 1290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * state.</li> 1300a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>It is good programming practice to have your application 1310a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * register a OnErrorListener to look out for error notifications from 1320a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the internal player engine.</li> 1330a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>IllegalStateException is 1340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * thrown to prevent programming errors such as calling 135d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia * {@link #prepare()}, {@link #setDataSource(DataSourceDesc)} 136d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia * methods in an invalid state. </li> 1370a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </ul> 1380a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </li> 1390a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>Calling 140d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia * {@link #setDataSource(DataSourceDesc)} transfers a 1410a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * MediaPlayer2 object in the <em>Idle</em> state to the 1420a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <em>Initialized</em> state. 1430a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <ul> 1440a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>An IllegalStateException is thrown if 145d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia * setDataSource() is called in any other state.</li> 1460a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>It is good programming 1470a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * practice to always look out for <code>IllegalArgumentException</code> 1480a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * and <code>IOException</code> that may be thrown from 149d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia * <code>setDataSource</code>.</li> 1500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </ul> 1510a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </li> 1520a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>A MediaPlayer2 object must first enter the <em>Prepared</em> state 1530a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * before playback can be started. 1540a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <ul> 1550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>There are an asynchronous way that the <em>Prepared</em> state can be reached: 1561789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * a call to {@link #prepare()} (asynchronous) which 1570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * first transfers the object to the <em>Preparing</em> state after the 1580a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * call returns (which occurs almost right way) while the internal 1590a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * player engine continues working on the rest of preparation work 1600a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * until the preparation work completes. When the preparation completes, 1610a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the internal player engine then calls a user supplied callback method, 1621789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * onInfo() of the MediaPlayer2EventCallback interface with {@link #MEDIA_INFO_PREPARED}, 1631789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * if an MediaPlayer2EventCallback is registered beforehand via 1641789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@link #setMediaPlayer2EventCallback(Executor, MediaPlayer2EventCallback)}.</li> 1650a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>It is important to note that 1660a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the <em>Preparing</em> state is a transient state, and the behavior 1670a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * of calling any method with side effect while a MediaPlayer2 object is 1680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * in the <em>Preparing</em> state is undefined.</li> 1690a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>An IllegalStateException is 1701789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * thrown if {@link #prepare()} is called in 1710a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * any other state.</li> 1720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>While in the <em>Prepared</em> state, properties 1730a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * such as audio/sound volume, screenOnWhilePlaying, looping can be 1740a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * adjusted by invoking the corresponding set methods.</li> 1750a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </ul> 1760a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </li> 1770a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>To start the playback, {@link #play()} must be called. After 1780a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link #play()} returns successfully, the MediaPlayer2 object is in the 1791789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * <em>Started</em> state. {@link #getPlayerState()} can be called to test 1800a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * whether the MediaPlayer2 object is in the <em>Started</em> state. 1810a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <ul> 1820a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>While in the <em>Started</em> state, the internal player engine calls 1831789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * a user supplied callback method MediaPlayer2EventCallback.onInfo() with 1841789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@link #MEDIA_INFO_BUFFERING_UPDATE} if an MediaPlayer2EventCallback has been 1851789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * registered beforehand via 1861789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@link #setMediaPlayer2EventCallback(Executor, MediaPlayer2EventCallback)}. 1870a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * This callback allows applications to keep track of the buffering status 1880a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * while streaming audio/video.</li> 1890a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>Calling {@link #play()} has not effect 1900a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * on a MediaPlayer2 object that is already in the <em>Started</em> state.</li> 1910a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </ul> 1920a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </li> 1930a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>Playback can be paused and stopped, and the current playback position 1940a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * can be adjusted. Playback can be paused via {@link #pause()}. When the call to 1950a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link #pause()} returns, the MediaPlayer2 object enters the 1960a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <em>Paused</em> state. Note that the transition from the <em>Started</em> 1970a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * state to the <em>Paused</em> state and vice versa happens 1980a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * asynchronously in the player engine. It may take some time before 1991789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * the state is updated in calls to {@link #getPlayerState()}, and it can be 2000a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * a number of seconds in the case of streamed content. 2010a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <ul> 2020a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>Calling {@link #play()} to resume playback for a paused 2030a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * MediaPlayer2 object, and the resumed playback 2040a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * position is the same as where it was paused. When the call to 2050a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link #play()} returns, the paused MediaPlayer2 object goes back to 2060a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the <em>Started</em> state.</li> 2070a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>Calling {@link #pause()} has no effect on 2080a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * a MediaPlayer2 object that is already in the <em>Paused</em> state.</li> 2090a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </ul> 2100a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </li> 2110a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>The playback position can be adjusted with a call to 2120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link #seekTo(long, int)}. 2130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <ul> 2140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>Although the asynchronuous {@link #seekTo(long, int)} 2150a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * call returns right away, the actual seek operation may take a while to 2160a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * finish, especially for audio/video being streamed. When the actual 2170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * seek operation completes, the internal player engine calls a user 21869d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * supplied MediaPlayer2EventCallback.onCallCompleted() with 21969d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * {@link #CALL_COMPLETED_SEEK_TO} 2201789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * if an MediaPlayer2EventCallback has been registered beforehand via 2211789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@link #setMediaPlayer2EventCallback(Executor, MediaPlayer2EventCallback)}.</li> 2220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>Please 2230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * note that {@link #seekTo(long, int)} can also be called in the other states, 2240a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * such as <em>Prepared</em>, <em>Paused</em> and <em>PlaybackCompleted 2250a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </em> state. When {@link #seekTo(long, int)} is called in those states, 2260a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * one video frame will be displayed if the stream has video and the requested 2270a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * position is valid. 2280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </li> 2290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>Furthermore, the actual current playback position 2300a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * can be retrieved with a call to {@link #getCurrentPosition()}, which 2310a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * is helpful for applications such as a Music player that need to keep 2320a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * track of the playback progress.</li> 2330a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </ul> 2340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </li> 2350a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>When the playback reaches the end of stream, the playback completes. 2360a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <ul> 2371789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * <li>If current source is set to loop by {@link #loopCurrent(boolean)}, 2381789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * the MediaPlayer2 object shall remain in the <em>Started</em> state.</li> 2390a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>If the looping mode was set to <var>false 2400a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </var>, the player engine calls a user supplied callback method, 2411789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * MediaPlayer2EventCallback.onCompletion(), if an MediaPlayer2EventCallback is 2421789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * registered beforehand via 2431789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@link #setMediaPlayer2EventCallback(Executor, MediaPlayer2EventCallback)}. 2440a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The invoke of the callback signals that the object is now in the <em> 2450a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * PlaybackCompleted</em> state.</li> 2460a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <li>While in the <em>PlaybackCompleted</em> 2470a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * state, calling {@link #play()} can restart the playback from the 2480a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * beginning of the audio/video source.</li> 2490a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </ul> 2500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 2510a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 2520a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <a name="Valid_and_Invalid_States"></a> 2530a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <h3>Valid and invalid states</h3> 2540a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 2550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <table border="0" cellspacing="0" cellpadding="0"> 2560a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>Method Name </p></td> 2570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Valid Sates </p></td> 2580a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Invalid States </p></td> 2590a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Comments </p></td></tr> 2600a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>attachAuxEffect </p></td> 2610a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted} </p></td> 2620a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle, Error} </p></td> 263d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia * <td>This method must be called after setDataSource. 2640a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Calling it does not change the object state. </p></td></tr> 2650a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>getAudioSessionId </p></td> 2660a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>any </p></td> 2670a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{} </p></td> 2680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>This method can be called in any state and calling it does not change 2690a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the object state. </p></td></tr> 2700a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>getCurrentPosition </p></td> 2710a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, 2720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * PlaybackCompleted} </p></td> 2730a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Error}</p></td> 2740a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Successful invoke of this method in a valid state does not change the 2750a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * state. Calling this method in an invalid state transfers the object 2760a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * to the <em>Error</em> state. </p></td></tr> 2770a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>getDuration </p></td> 2780a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Prepared, Started, Paused, Stopped, PlaybackCompleted} </p></td> 2790a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle, Initialized, Error} </p></td> 2800a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Successful invoke of this method in a valid state does not change the 2810a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * state. Calling this method in an invalid state transfers the object 2820a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * to the <em>Error</em> state. </p></td></tr> 2830a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>getVideoHeight </p></td> 2840a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, 2850a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * PlaybackCompleted}</p></td> 2860a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Error}</p></td> 2870a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Successful invoke of this method in a valid state does not change the 2880a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * state. Calling this method in an invalid state transfers the object 2890a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * to the <em>Error</em> state. </p></td></tr> 2900a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>getVideoWidth </p></td> 2910a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, 2920a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * PlaybackCompleted}</p></td> 2930a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Error}</p></td> 2940a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Successful invoke of this method in a valid state does not change 2950a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the state. Calling this method in an invalid state transfers the 2960a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * object to the <em>Error</em> state. </p></td></tr> 2971789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * <tr><td>getPlayerState </p></td> 2980a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, 2990a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * PlaybackCompleted}</p></td> 3000a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Error}</p></td> 3010a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Successful invoke of this method in a valid state does not change 3020a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the state. Calling this method in an invalid state transfers the 3030a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * object to the <em>Error</em> state. </p></td></tr> 3040a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>pause </p></td> 3050a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Started, Paused, PlaybackCompleted}</p></td> 3060a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle, Initialized, Prepared, Stopped, Error}</p></td> 3070a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Successful invoke of this method in a valid state transfers the 3080a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * object to the <em>Paused</em> state. Calling this method in an 3090a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * invalid state transfers the object to the <em>Error</em> state.</p></td></tr> 3101789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * <tr><td>prepare </p></td> 3110a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Initialized, Stopped} </p></td> 3120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle, Prepared, Started, Paused, PlaybackCompleted, Error} </p></td> 3130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Successful invoke of this method in a valid state transfers the 3140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * object to the <em>Preparing</em> state. Calling this method in an 3150a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * invalid state throws an IllegalStateException.</p></td></tr> 3160a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>release </p></td> 3170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>any </p></td> 3180a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{} </p></td> 3190a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>After {@link #close()}, the object is no longer available. </p></td></tr> 3200a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>reset </p></td> 3210a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, 3220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * PlaybackCompleted, Error}</p></td> 3230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{}</p></td> 3240a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>After {@link #reset()}, the object is like being just created.</p></td></tr> 3250a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>seekTo </p></td> 3260a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Prepared, Started, Paused, PlaybackCompleted} </p></td> 3270a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle, Initialized, Stopped, Error}</p></td> 3280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Successful invoke of this method in a valid state does not change 3290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the state. Calling this method in an invalid state transfers the 3300a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * object to the <em>Error</em> state. </p></td></tr> 3310a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>setAudioAttributes </p></td> 3320a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, 3330a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * PlaybackCompleted}</p></td> 3340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Error}</p></td> 3350a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Successful invoke of this method does not change the state. In order for the 3360a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * target audio attributes type to become effective, this method must be called before 3371789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * prepare().</p></td></tr> 3380a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>setAudioSessionId </p></td> 3390a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle} </p></td> 3400a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted, 3410a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Error} </p></td> 3420a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>This method must be called in idle state as the audio session ID must be known before 343d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia * calling setDataSource. Calling it does not change the object 3440a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * state. </p></td></tr> 3450a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>setAudioStreamType (deprecated)</p></td> 3460a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, 3470a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * PlaybackCompleted}</p></td> 3480a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Error}</p></td> 3490a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Successful invoke of this method does not change the state. In order for the 3500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * target audio stream type to become effective, this method must be called before 3511789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * prepare().</p></td></tr> 3520a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>setAuxEffectSendLevel </p></td> 3530a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>any</p></td> 3540a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{} </p></td> 3550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Calling this method does not change the object state. </p></td></tr> 3560a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>setDataSource </p></td> 3570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle} </p></td> 3580a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted, 3590a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Error} </p></td> 3600a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Successful invoke of this method in a valid state transfers the 3610a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * object to the <em>Initialized</em> state. Calling this method in an 3620a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * invalid state throws an IllegalStateException.</p></td></tr> 3630a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>setDisplay </p></td> 3640a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>any </p></td> 3650a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{} </p></td> 3660a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>This method can be called in any state and calling it does not change 3670a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the object state. </p></td></tr> 3680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>setSurface </p></td> 3690a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>any </p></td> 3700a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{} </p></td> 3710a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>This method can be called in any state and calling it does not change 3720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the object state. </p></td></tr> 3731789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * <tr><td>loopCurrent </p></td> 3740a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, 3750a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * PlaybackCompleted}</p></td> 3760a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Error}</p></td> 3770a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Successful invoke of this method in a valid state does not change 3780a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the state. Calling this method in an 3790a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * invalid state transfers the object to the <em>Error</em> state.</p></td></tr> 3800a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>isLooping </p></td> 3810a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>any </p></td> 3820a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{} </p></td> 3830a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>This method can be called in any state and calling it does not change 3840a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the object state. </p></td></tr> 3851789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * <tr><td>setDrmEventCallback </p></td> 3860a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>any </p></td> 3870a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{} </p></td> 3880a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>This method can be called in any state and calling it does not change 3890a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the object state. </p></td></tr> 3901789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * <tr><td>setMediaPlayer2EventCallback </p></td> 3910a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>any </p></td> 3920a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{} </p></td> 3930a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>This method can be called in any state and calling it does not change 3940a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the object state. </p></td></tr> 3950a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>setPlaybackParams</p></td> 3960a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Initialized, Prepared, Started, Paused, PlaybackCompleted, Error}</p></td> 3970a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle, Stopped} </p></td> 3980a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>This method will change state in some cases, depending on when it's called. 3990a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </p></td></tr> 4001789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * <tr><td>setPlayerVolume </p></td> 4010a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, 4020a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * PlaybackCompleted}</p></td> 4030a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Error}</p></td> 4040a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Successful invoke of this method does not change the state. 4050a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>play </p></td> 4060a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Prepared, Started, Paused, PlaybackCompleted}</p></td> 4070a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle, Initialized, Stopped, Error}</p></td> 4080a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Successful invoke of this method in a valid state transfers the 4090a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * object to the <em>Started</em> state. Calling this method in an 4100a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * invalid state transfers the object to the <em>Error</em> state.</p></td></tr> 4110a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>stop </p></td> 4120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Prepared, Started, Stopped, Paused, PlaybackCompleted}</p></td> 4130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle, Initialized, Error}</p></td> 4140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Successful invoke of this method in a valid state transfers the 4150a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * object to the <em>Stopped</em> state. Calling this method in an 4160a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * invalid state transfers the object to the <em>Error</em> state.</p></td></tr> 4170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>getTrackInfo </p></td> 4180a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Prepared, Started, Stopped, Paused, PlaybackCompleted}</p></td> 4190a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle, Initialized, Error}</p></td> 4200a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Successful invoke of this method does not change the state.</p></td></tr> 4210a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>selectTrack </p></td> 4220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Prepared, Started, Stopped, Paused, PlaybackCompleted}</p></td> 4230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle, Initialized, Error}</p></td> 4240a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Successful invoke of this method does not change the state.</p></td></tr> 4250a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <tr><td>deselectTrack </p></td> 4260a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Prepared, Started, Stopped, Paused, PlaybackCompleted}</p></td> 4270a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>{Idle, Initialized, Error}</p></td> 4280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <td>Successful invoke of this method does not change the state.</p></td></tr> 4290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 4300a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </table> 4310a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 4320a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <a name="Permissions"></a> 4330a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <h3>Permissions</h3> 4340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p>One may need to declare a corresponding WAKE_LOCK permission {@link 4350a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * android.R.styleable#AndroidManifestUsesPermission <uses-permission>} 4360a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * element. 4370a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 4380a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p>This class requires the {@link android.Manifest.permission#INTERNET} permission 4390a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * when used with network-based content. 4400a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 4410a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <a name="Callbacks"></a> 4420a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <h3>Callbacks</h3> 4430a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p>Applications may want to register for informational and error 4440a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * events in order to be informed of some internal state update and 4450a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * possible runtime errors during playback or streaming. Registration for 4460a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * these events is done by properly setting the appropriate listeners (via calls 4470a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * to 4481789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@link #setMediaPlayer2EventCallback(Executor, MediaPlayer2EventCallback)}, 4491789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@link #setDrmEventCallback(Executor, DrmEventCallback)}). 4500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * In order to receive the respective callback 4510a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * associated with these listeners, applications are required to create 4520a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * MediaPlayer2 objects on a thread with its own Looper running (main UI 4530a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * thread by default has a Looper running). 4540a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 4550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 4561789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jiapublic abstract class MediaPlayer2 extends MediaPlayerBase 4571789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia implements SubtitleController.Listener 4581789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia , AudioRouting { 4590a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 4600a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Create a MediaPlayer2 object. 4610a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 4620a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @return A MediaPlayer2 object created 4630a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 4640a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final MediaPlayer2 create() { 4650a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia // TODO: load MediaUpdate APK 4660a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia return new MediaPlayer2Impl(); 4670a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia } 4680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 4693164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih private static final String[] decodeMediaPlayer2Uri(String location) { 4703164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih Uri uri = Uri.parse(location); 4713164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih if (!"mediaplayer2".equals(uri.getScheme())) { 4723164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih return new String[] {location}; 4733164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih } 4743164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih 4753164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih List<String> uris = uri.getQueryParameters("uri"); 4763164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih if (uris.isEmpty()) { 4773164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih return new String[] {location}; 4783164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih } 4793164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih 4803164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih List<String> keys = uri.getQueryParameters("key"); 4813164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih List<String> values = uri.getQueryParameters("value"); 4823164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih if (keys.size() != values.size()) { 4833164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih return new String[] {uris.get(0)}; 4843164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih } 4853164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih 4863164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih List<String> ls = new ArrayList(); 4873164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih ls.add(uris.get(0)); 4883164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih for (int i = 0; i < keys.size() ; i++) { 4893164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih ls.add(keys.get(i)); 4903164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih ls.add(values.get(i)); 4913164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih } 4923164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih 4933164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih return ls.toArray(new String[ls.size()]); 4943164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih } 4953164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih 4963164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih private static final String encodeMediaPlayer2Uri(String uri, String[] keys, String[] values) { 4973164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih Uri.Builder builder = new Uri.Builder(); 4983164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih builder.scheme("mediaplayer2").path("/").appendQueryParameter("uri", uri); 4993164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih if (keys == null || values == null || keys.length != values.length) { 5003164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih return builder.build().toString(); 5013164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih } 5023164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih for (int i = 0; i < keys.length ; i++) { 5033164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih builder 5043164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih .appendQueryParameter("key", keys[i]) 5053164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih .appendQueryParameter("value", values[i]); 5063164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih } 5073164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih return builder.build().toString(); 5083164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih } 5093164cbd536b13a803ca2944ff3d64c8e2c96e769Robert Shih 5100a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 5110a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 5120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 5130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia // add hidden empty constructor so it doesn't show in SDK 5140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public MediaPlayer2() { } 5150a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 5160a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 5171789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Releases the resources held by this {@code MediaPlayer2} object. 5180a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 5191789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * It is considered good practice to call this method when you're 5201789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * done using the MediaPlayer2. In particular, whenever an Activity 5211789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * of an application is paused (its onPause() method is called), 5221789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * or stopped (its onStop() method is called), this method should be 5231789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * invoked to release the MediaPlayer2 object, unless the application 5241789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * has a special need to keep the object around. In addition to 5251789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * unnecessary resources (such as memory and instances of codecs) 5261789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * being held, failure to call this method immediately if a 5271789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * MediaPlayer2 object is no longer needed may also lead to 5281789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * continuous battery consumption for mobile devices, and playback 5291789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * failure for other applications if no multiple instances of the 5301789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * same codec are supported on a device. Even if multiple instances 5311789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * of the same codec are supported, some performance degradation 5321789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * may be expected when unnecessary multiple instances are used 5331789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * at the same time. 5341789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * 5351789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@code close()} may be safely called after a prior {@code close()}. 5361789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * This class implements the Java {@code AutoCloseable} interface and 5371789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * may be used with try-with-resources. 5380a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 539d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is a synchronous call. 5401789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 5411789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void close(); 5420a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 5430a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 5441789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Starts or resumes playback. If playback had previously been paused, 5451789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * playback will continue from where it was paused. If playback had 5461789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * reached end of stream and been paused, or never started before, 5471789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * playback will start at the beginning. If the source had not been 5481789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * prepared, the player will prepare the source and play. 5490a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 5500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 551d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 5521789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 5531789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void play(); 5540a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 5550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 5561789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Prepares the player for playback, asynchronously. 5570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 5581789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * After setting the datasource and the display surface, you need to 5591789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * call prepare(). 5600a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 5610a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 562d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 5631789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 5641789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void prepare(); 5650a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 5660a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 5671789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Pauses playback. Call play() to resume. 5680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 569d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 5701789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 5711789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void pause(); 5720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 5731789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 5741789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Tries to play next data source if applicable. 5750a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 576d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 5771789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 5781789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void skipToNext(); 5791789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 5800a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 5811789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Moves the media to specified time position. 5821789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Same as {@link #seekTo(long, int)} with {@code mode = SEEK_PREVIOUS_SYNC}. 5831789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * 5841789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param msec the offset in milliseconds from the start to seek to 5850a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 586d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 5871789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 5881789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public void seekTo(long msec) { 5891789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia seekTo(msec, SEEK_PREVIOUS_SYNC /* mode */); 5901789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia } 5910a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 5920a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 5931789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Gets the current playback position. 5941789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * 5951789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @return the current position in milliseconds 5960a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 5971789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 5981789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract long getCurrentPosition(); 5990a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 6000a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 6011789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Gets the duration of the file. 6020a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 6031789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @return the duration in milliseconds, if no duration is available 6041789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * (for example, if streaming live content), -1 is returned. 6051789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 6061789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 6071789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract long getDuration(); 6081789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 6091789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 6101789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Gets the current buffered media source position received through progressive downloading. 6111789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * The received buffering percentage indicates how much of the content has been buffered 6121789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * or played. For example a buffering update of 80 percent when half the content 6131789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * has already been played indicates that the next 30 percent of the 6141789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * content to play has been buffered. 6150a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 6161789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @return the current buffered media source position in milliseconds 6171789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 6181789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 6191789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract long getBufferedPosition(); 6201789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 6211789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 6221789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Gets the current player state. 6230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 6241789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @return the current player state. 6250a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 6261789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 6271789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract @PlayerState int getPlayerState(); 6280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 6290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 6301789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Gets the current buffering state of the player. 6311789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * During buffering, see {@link #getBufferedPosition()} for the quantifying the amount already 6321789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * buffered. 6331789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @return the buffering state, one of the following: 6340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 6351789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 6361789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract @BuffState int getBufferingState(); 6371789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 6381789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 6391789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Sets the audio attributes for this MediaPlayer2. 6401789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * See {@link AudioAttributes} for how to build and configure an instance of this class. 6411789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * You must call this method before {@link #prepare()} in order 6421789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * for the audio attributes to become effective thereafter. 6431789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param attributes a non-null set of audio attributes 6441789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 645d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 6461789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 6471789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void setAudioAttributes(@NonNull AudioAttributes attributes); 6481789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 6491789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 6501789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Gets the audio attributes for this MediaPlayer2. 6511789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @return attributes a set of audio attributes 6521789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 6531789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 6541789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract @Nullable AudioAttributes getAudioAttributes(); 6550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 6560a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 6570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Sets the data source as described by a DataSourceDesc. 6580a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 6590a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param dsd the descriptor of data source you want to play 6600a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 661d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 6621789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 6631789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void setDataSource(@NonNull DataSourceDesc dsd); 6640a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 6650a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 6661789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Sets a single data source as described by a DataSourceDesc which will be played 6671789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * after current data source is finished. 6680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 6691789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param dsd the descriptor of data source you want to play after current one 6700a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 671d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 6721789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 6731789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void setNextDataSource(@NonNull DataSourceDesc dsd); 6740a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 6750a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 6761789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Sets a list of data sources to be played sequentially after current data source is done. 6770a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 6781789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param dsds the list of data sources you want to play after current one 6790a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 680d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 6811789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 6821789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void setNextDataSources(@NonNull List<DataSourceDesc> dsds); 6830a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 6840a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 6851789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Gets the current data source as described by a DataSourceDesc. 6860a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 6871789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @return the current DataSourceDesc 6880a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 6891789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 6901789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract @NonNull DataSourceDesc getCurrentDataSource(); 6910a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 6920a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 6931789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Configures the player to loop on the current data source. 6941789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param loop true if the current data source is meant to loop. 6950a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 696d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 6971789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 6981789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void loopCurrent(boolean loop); 6990a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 7000a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 7011789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Sets the playback speed. 7021789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * A value of 1.0f is the default playback value. 7031789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * A negative value indicates reverse playback, check {@link #isReversePlaybackSupported()} 7041789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * before using negative values.<br> 7051789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * After changing the playback speed, it is recommended to query the actual speed supported 7061789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * by the player, see {@link #getPlaybackSpeed()}. 7071789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param speed the desired playback speed 7080a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 709d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 7101789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 7111789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void setPlaybackSpeed(float speed); 7120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 7130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 7141789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Returns the actual playback speed to be used by the player when playing. 7151789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Note that it may differ from the speed set in {@link #setPlaybackSpeed(float)}. 7161789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @return the actual playback speed 7170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 7181789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 7191789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public float getPlaybackSpeed() { 7201789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia return 1.0f; 7211789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia } 7220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 7230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 7241789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Indicates whether reverse playback is supported. 7251789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Reverse playback is indicated by negative playback speeds, see 7261789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@link #setPlaybackSpeed(float)}. 7271789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @return true if reverse playback is supported. 7280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 7291789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 7301789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public boolean isReversePlaybackSupported() { 7311789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia return false; 7321789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia } 7331789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 7340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 7351789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Sets the volume of the audio of the media to play, expressed as a linear multiplier 7361789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * on the audio samples. 7371789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Note that this volume is specific to the player, and is separate from stream volume 7381789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * used across the platform.<br> 7391789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * A value of 0.0f indicates muting, a value of 1.0f is the nominal unattenuated and unamplified 7401789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * gain. See {@link #getMaxPlayerVolume()} for the volume range supported by this player. 7411789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param volume a value between 0.0f and {@link #getMaxPlayerVolume()}. 7420a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 743d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 7441789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 7451789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void setPlayerVolume(float volume); 7461789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 7470a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 7481789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Returns the current volume of this player to this player. 7491789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Note that it does not take into account the associated stream volume. 7501789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @return the player volume. 7510a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 7521789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 7531789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract float getPlayerVolume(); 7541789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 7550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 7561789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @return the maximum volume that can be used in {@link #setPlayerVolume(float)}. 7570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 7581789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 7591789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public float getMaxPlayerVolume() { 7601789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia return 1.0f; 7611789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia } 7620a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 7631789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 7641789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Adds a callback to be notified of events for this player. 7651789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param e the {@link Executor} to be used for the events. 7661789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param cb the callback to receive the events. 7671789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 768d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is a synchronous call. 7691789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 7701789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void registerPlayerEventCallback(@NonNull Executor e, 7711789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @NonNull PlayerEventCallback cb); 7720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 7730a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 7741789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Removes a previously registered callback for player events 7751789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param cb the callback to remove 7760a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 777d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is a synchronous call. 7781789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Override 7791789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void unregisterPlayerEventCallback(@NonNull PlayerEventCallback cb); 7800a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 7810a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 7821789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Create a request parcel which can be routed to the native media 7831789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * player using {@link #invoke(Parcel, Parcel)}. The Parcel 7841789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * returned has the proper InterfaceToken set. The caller should 7851789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * not overwrite that token, i.e it can only append data to the 7861789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Parcel. 7870a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 7881789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @return A parcel suitable to hold a request for the native 7891789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * player. 7901789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@hide} 7910a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 7921789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public Parcel newRequest() { 7931789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia return null; 7941789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia } 7950a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 7960a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 7971789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Invoke a generic method on the native player using opaque 7981789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * parcels for the request and reply. Both payloads' format is a 7991789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * convention between the java caller and the native player. 800d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia * Must be called after setDataSource to make sure a native player 8011789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * exists. On failure, a RuntimeException is thrown. 8021789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * 8031789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param request Parcel with the data for the extension. The 8041789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * caller must use {@link #newRequest()} to get one. 8050a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 8061789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param reply Output parcel with the data returned by the 8071789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * native player. 8081789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@hide} 8090a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 8101789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public void invoke(Parcel request, Parcel reply) { } 8110a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 8120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 8131789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Insert a task in the command queue to help the client to identify whether a batch 8141789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * of commands has been finished. When this command is processed, a notification 8151789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@code MediaPlayer2EventCallback.onCommandLabelReached} will be fired with the 8161789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * given {@code label}. 8170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 8181789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCommandLabelReached 8190a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 8201789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param label An application specific Object used to help to identify the completeness 8211789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * of a batch of commands. 8220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 823d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 82469d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public void notifyWhenCommandLabelReached(@NonNull Object label) { } 8250a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 8260a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 8271789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Sets the {@link SurfaceHolder} to use for displaying the video 8281789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * portion of the media. 8290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 8301789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Either a surface holder or surface must be set if a display or video sink 8311789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * is needed. Not calling this method or {@link #setSurface(Surface)} 8321789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * when playing back a video will result in only the audio track being played. 8331789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * A null surface holder or surface will result in only the audio track being 8341789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * played. 8350a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 8361789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param sh the SurfaceHolder to use for video display 8371789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @throws IllegalStateException if the internal player engine has not been 8381789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * initialized or has been released. 8391789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @hide 8400a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 8411789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void setDisplay(SurfaceHolder sh); 8420a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 8430a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 8441789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Sets the {@link Surface} to be used as the sink for the video portion of 8451789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * the media. Setting a 8461789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Surface will un-set any Surface or SurfaceHolder that was previously set. 8471789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * A null surface will result in only the audio track being played. 8480a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 8491789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * If the Surface sends frames to a {@link SurfaceTexture}, the timestamps 8501789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * returned from {@link SurfaceTexture#getTimestamp()} will have an 8511789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * unspecified zero point. These timestamps cannot be directly compared 8521789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * between different media sources, different instances of the same media 8531789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * source, or multiple runs of the same program. The timestamp is normally 8541789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * monotonically increasing and is unaffected by time-of-day adjustments, 8551789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * but it is reset when the position is set. 8560a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 8571789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param surface The {@link Surface} to be used for the video portion of 8581789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * the media. 8591789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @throws IllegalStateException if the internal player engine has not been 8601789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * initialized or has been released. 8611789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 862d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 8631789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void setSurface(Surface surface); 8641789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 8651789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /* Do not change these video scaling mode values below without updating 8661789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * their counterparts in system/window.h! Please do not forget to update 8671789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@link #isVideoScalingModeSupported} when new video scaling modes 8681789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * are added. 8691789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 8701789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 8711789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Specifies a video scaling mode. The content is stretched to the 8721789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * surface rendering area. When the surface has the same aspect ratio 8731789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * as the content, the aspect ratio of the content is maintained; 8741789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * otherwise, the aspect ratio of the content is not maintained when video 8751789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * is being rendered. 8761789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * There is no content cropping with this video scaling mode. 8771789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 8781789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT = 1; 8791789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 8801789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 8811789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Specifies a video scaling mode. The content is scaled, maintaining 8821789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * its aspect ratio. The whole surface area is always used. When the 8831789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * aspect ratio of the content is the same as the surface, no content 8841789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * is cropped; otherwise, content is cropped to fit the surface. 8851789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @hide 8860a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 8871789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING = 2; 8880a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 8890a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 8901789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Sets video scaling mode. To make the target video scaling mode 8911789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * effective during playback, this method must be called after 8921789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * data source is set. If not called, the default video 8931789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * scaling mode is {@link #VIDEO_SCALING_MODE_SCALE_TO_FIT}. 8940a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 8951789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * <p> The supported video scaling modes are: 8961789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * <ul> 8971789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * <li> {@link #VIDEO_SCALING_MODE_SCALE_TO_FIT} 8981789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * </ul> 8991789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * 9001789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param mode target video scaling mode. Must be one of the supported 9011789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * video scaling modes; otherwise, IllegalArgumentException will be thrown. 9020a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 9031789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see MediaPlayer2#VIDEO_SCALING_MODE_SCALE_TO_FIT 9041789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @hide 9050a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 9061789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public void setVideoScalingMode(int mode) { } 9070a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 9080a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 9091789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Discards all pending commands. 9100a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 911d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is a synchronous call. 9121789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void clearPendingCommands(); 9130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 9140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 9150a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Stops playback after playback has been started or paused. 9160a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 9170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IllegalStateException if the internal player engine has not been 9180a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * initialized. 9190a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 9200a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 9210a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public void stop() { } 9220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 9230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia //-------------------------------------------------------------------------- 9240a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia // Explicit Routing 9250a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia //-------------------- 9260a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 9270a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 9280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Specifies an audio device (via an {@link AudioDeviceInfo} object) to route 9290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the output from this MediaPlayer2. 9300a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param deviceInfo The {@link AudioDeviceInfo} specifying the audio sink or source. 9310a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * If deviceInfo is null, default routing is restored. 9320a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @return true if succesful, false if the specified {@link AudioDeviceInfo} is non-null and 9330a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * does not correspond to a valid audio device. 9340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 935d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 9360a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia @Override 9370a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract boolean setPreferredDevice(AudioDeviceInfo deviceInfo); 9380a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 9390a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 9400a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Returns the selected output specified by {@link #setPreferredDevice}. Note that this 9410a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * is not guaranteed to correspond to the actual device being used for playback. 9420a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 9430a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia @Override 9440a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract AudioDeviceInfo getPreferredDevice(); 9450a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 9460a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 9470a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Returns an {@link AudioDeviceInfo} identifying the current routing of this MediaPlayer2 9480a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Note: The query is only valid if the MediaPlayer2 is currently playing. 9490a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * If the player is not playing, the returned device can be null or correspond to previously 9500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * selected device when the player was last active. 9510a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 9520a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia @Override 9530a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract AudioDeviceInfo getRoutedDevice(); 9540a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 9550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 9560a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Adds an {@link AudioRouting.OnRoutingChangedListener} to receive notifications of routing 9570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * changes on this MediaPlayer2. 9580a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param listener The {@link AudioRouting.OnRoutingChangedListener} interface to receive 9590a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * notifications of rerouting events. 9600a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param handler Specifies the {@link Handler} object for the thread on which to execute 9610a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the callback. If <code>null</code>, the handler on the main looper will be used. 9620a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 963d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is a synchronous call. 9640a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia @Override 9650a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract void addOnRoutingChangedListener(AudioRouting.OnRoutingChangedListener listener, 9660a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia Handler handler); 9670a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 9680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 9690a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Removes an {@link AudioRouting.OnRoutingChangedListener} which has been previously added 9700a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * to receive rerouting notifications. 9710a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param listener The previously added {@link AudioRouting.OnRoutingChangedListener} interface 9720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * to remove. 9730a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 974d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is a synchronous call. 9750a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia @Override 9760a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract void removeOnRoutingChangedListener(AudioRouting.OnRoutingChangedListener listener); 9770a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 9780a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 9790a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Set the low-level power management behavior for this MediaPlayer2. 9800a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 9810a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p>This function has the MediaPlayer2 access the low-level power manager 9820a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * service to control the device's power usage while playing is occurring. 9830a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The parameter is a combination of {@link android.os.PowerManager} wake flags. 9840a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Use of this method requires {@link android.Manifest.permission#WAKE_LOCK} 9850a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * permission. 9860a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * By default, no attempt is made to keep the device awake during playback. 9870a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 9880a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param context the Context to use 9890a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param mode the power/wake mode to set 9900a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @see android.os.PowerManager 9910a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 9920a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 9930a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract void setWakeMode(Context context, int mode); 9940a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 9950a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 9960a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Control whether we should use the attached SurfaceHolder to keep the 9970a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * screen on while video playback is occurring. This is the preferred 9980a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * method over {@link #setWakeMode} where possible, since it doesn't 9990a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * require that the application have permission for low-level wake lock 10000a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * access. 10010a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 10020a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param screenOn Supply true to keep the screen on, false to allow it 10030a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * to turn off. 10040a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 10050a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 10060a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract void setScreenOnWhilePlaying(boolean screenOn); 10070a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 10080a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 10090a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Returns the width of the video. 10100a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 10110a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @return the width of the video, or 0 if there is no video, 10120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * no display surface was set, or the width has not been determined 10131789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * yet. The {@code MediaPlayer2EventCallback} can be registered via 10141789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@link #setMediaPlayer2EventCallback(Executor, MediaPlayer2EventCallback)} to provide a 10151789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * notification {@code MediaPlayer2EventCallback.onVideoSizeChanged} when the width 10161789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * is available. 10170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 10180a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract int getVideoWidth(); 10190a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 10200a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 10210a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Returns the height of the video. 10220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 10230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @return the height of the video, or 0 if there is no video, 10240a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * no display surface was set, or the height has not been determined 10251789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * yet. The {@code MediaPlayer2EventCallback} can be registered via 10261789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@link #setMediaPlayer2EventCallback(Executor, MediaPlayer2EventCallback)} to provide a 10271789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * notification {@code MediaPlayer2EventCallback.onVideoSizeChanged} when the height is available. 10280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 10290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract int getVideoHeight(); 10300a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 10310a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 10320a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Return Metrics data about the current player. 10330a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 10340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @return a {@link PersistableBundle} containing the set of attributes and values 10350a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * available for the media being handled by this instance of MediaPlayer2 10360a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The attributes are descibed in {@link MetricsConstants}. 10370a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 10380a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Additional vendor-specific fields may also be present in 10390a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the return value. 10400a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 10410a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract PersistableBundle getMetrics(); 10420a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 10430a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 10440a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Checks whether the MediaPlayer2 is playing. 10450a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 10460a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @return true if currently playing, false otherwise 10470a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IllegalStateException if the internal player engine has not been 10480a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * initialized or has been released. 10491789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @hide 10500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 10510a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract boolean isPlaying(); 10520a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 10530a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 10541789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * MediaPlayer2 has not been prepared or just has been reset. 10551789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * In this state, MediaPlayer2 doesn't fetch data. 105669d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @hide 10571789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 10581789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public static final int MEDIAPLAYER2_STATE_IDLE = 1; 10591789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 10601789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 10611789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * MediaPlayer2 has been just prepared. 10621789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * In this state, MediaPlayer2 just fetches data from media source, 10631789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * but doesn't actively render data. 106469d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @hide 10651789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 10661789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public static final int MEDIAPLAYER2_STATE_PREPARED = 2; 10671789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 10681789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 10691789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * MediaPlayer2 is paused. 10701789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * In this state, MediaPlayer2 doesn't actively render data. 107169d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @hide 10721789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 10731789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public static final int MEDIAPLAYER2_STATE_PAUSED = 3; 10741789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 10751789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 10761789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * MediaPlayer2 is actively playing back data. 107769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @hide 10781789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 10791789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public static final int MEDIAPLAYER2_STATE_PLAYING = 4; 10801789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 10811789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 10821789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * MediaPlayer2 has hit some fatal error and cannot continue playback. 108369d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @hide 10841789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 10851789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public static final int MEDIAPLAYER2_STATE_ERROR = 5; 10861789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 10871789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 10881789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @hide 10891789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 109069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang @IntDef(flag = false, prefix = "MEDIAPLAYER2_STATE", value = { 10911789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia MEDIAPLAYER2_STATE_IDLE, 10921789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia MEDIAPLAYER2_STATE_PREPARED, 10931789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia MEDIAPLAYER2_STATE_PAUSED, 10941789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia MEDIAPLAYER2_STATE_PLAYING, 10951789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia MEDIAPLAYER2_STATE_ERROR }) 10961789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Retention(RetentionPolicy.SOURCE) 10971789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public @interface MediaPlayer2State {} 10981789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 10991789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 11001789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Gets the current MediaPlayer2 state. 11011789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * 11021789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @return the current MediaPlayer2 state. 110369d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @hide 11041789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 11051789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract @MediaPlayer2State int getMediaPlayer2State(); 11061789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 11071789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 11080a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Gets the current buffering management params used by the source component. 11090a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Calling it only after {@code setDataSource} has been called. 11100a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Each type of data source might have different set of default params. 11110a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 11120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @return the current buffering management params used by the source component. 11130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IllegalStateException if the internal player engine has not been 11140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * initialized, or {@code setDataSource} has not been called. 11150a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 11160a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 11170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia @NonNull 11180a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public BufferingParams getBufferingParams() { 11190a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia return new BufferingParams.Builder().build(); 11200a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia } 11210a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 11220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 11230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Sets buffering management params. 11240a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The object sets its internal BufferingParams to the input, except that the input is 11250a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * invalid or not supported. 11260a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Call it only after {@code setDataSource} has been called. 11270a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The input is a hint to MediaPlayer2. 11280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 11290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param params the buffering management params. 11300a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 11310a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IllegalStateException if the internal player engine has not been 11320a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * initialized or has been released, or {@code setDataSource} has not been called. 11330a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IllegalArgumentException if params is invalid or not supported. 11340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 11350a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 1136d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 11370a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public void setBufferingParams(@NonNull BufferingParams params) { } 11380a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 11390a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 11400a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Change playback speed of audio by resampling the audio. 11410a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 11420a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Specifies resampling as audio mode for variable rate playback, i.e., 11430a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * resample the waveform based on the requested playback rate to get 11440a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * a new waveform, and play back the new waveform at the original sampling 11450a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * frequency. 11460a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * When rate is larger than 1.0, pitch becomes higher. 11470a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * When rate is smaller than 1.0, pitch becomes lower. 11480a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 11490a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 11500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 11510a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int PLAYBACK_RATE_AUDIO_MODE_RESAMPLE = 2; 11520a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 11530a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 11540a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Change playback speed of audio without changing its pitch. 11550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 11560a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Specifies time stretching as audio mode for variable rate playback. 11570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Time stretching changes the duration of the audio samples without 11580a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * affecting its pitch. 11590a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 11600a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * This mode is only supported for a limited range of playback speed factors, 11610a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * e.g. between 1/2x and 2x. 11620a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 11630a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 11640a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 11650a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int PLAYBACK_RATE_AUDIO_MODE_STRETCH = 1; 11660a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 11670a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 11680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Change playback speed of audio without changing its pitch, and 11690a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * possibly mute audio if time stretching is not supported for the playback 11700a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * speed. 11710a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 11720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Try to keep audio pitch when changing the playback rate, but allow the 11730a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * system to determine how to change audio playback if the rate is out 11740a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * of range. 11750a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 11760a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 11770a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 11780a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int PLAYBACK_RATE_AUDIO_MODE_DEFAULT = 0; 11790a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 11800a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** @hide */ 118169d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang @IntDef(flag = false, prefix = "PLAYBACK_RATE_AUDIO_MODE", value = { 11820a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia PLAYBACK_RATE_AUDIO_MODE_DEFAULT, 11830a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia PLAYBACK_RATE_AUDIO_MODE_STRETCH, 11840a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia PLAYBACK_RATE_AUDIO_MODE_RESAMPLE, 11850a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia }) 11860a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia @Retention(RetentionPolicy.SOURCE) 11870a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public @interface PlaybackRateAudioMode {} 11880a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 11890a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 11900a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Sets playback rate and audio mode. 11910a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 11920a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param rate the ratio between desired playback rate and normal one. 11930a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param audioMode audio playback mode. Must be one of the supported 11940a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * audio modes. 11950a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 11960a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IllegalStateException if the internal player engine has not been 11970a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * initialized. 11980a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IllegalArgumentException if audioMode is not supported. 11990a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 12000a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 12010a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 12020a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia @NonNull 12030a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public PlaybackParams easyPlaybackParams(float rate, @PlaybackRateAudioMode int audioMode) { 12040a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia return new PlaybackParams(); 12050a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia } 12060a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 12070a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 12080a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Sets playback rate using {@link PlaybackParams}. The object sets its internal 12090a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * PlaybackParams to the input, except that the object remembers previous speed 12100a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * when input speed is zero. This allows the object to resume at previous speed 12110a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * when play() is called. Calling it before the object is prepared does not change 12120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the object state. After the object is prepared, calling it with zero speed is 12130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * equivalent to calling pause(). After the object is prepared, calling it with 12140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * non-zero speed is equivalent to calling play(). 12150a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 12160a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param params the playback params. 12170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 1218d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 12190a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract void setPlaybackParams(@NonNull PlaybackParams params); 12200a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 12210a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 12220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Gets the playback params, containing the current playback rate. 12230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 12240a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @return the playback params. 12250a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 12260a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia @NonNull 12270a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract PlaybackParams getPlaybackParams(); 12280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 12290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 12300a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Sets A/V sync mode. 12310a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 12320a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param params the A/V sync params to apply 12330a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 1234d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 12350a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract void setSyncParams(@NonNull SyncParams params); 12360a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 12370a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 12380a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Gets the A/V sync mode. 12390a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 12400a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @return the A/V sync params 12410a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 12420a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia @NonNull 12430a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract SyncParams getSyncParams(); 12440a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 12450a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 12460a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Seek modes used in method seekTo(long, int) to move media position 12470a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * to a specified location. 12480a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 12490a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Do not change these mode values without updating their counterparts 12500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * in include/media/IMediaSource.h! 12510a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 12520a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 12530a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * This mode is used with {@link #seekTo(long, int)} to move media position to 12540a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * a sync (or key) frame associated with a data source that is located 12550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * right before or at the given time. 12560a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 12570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @see #seekTo(long, int) 12580a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 12590a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int SEEK_PREVIOUS_SYNC = 0x00; 12600a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 12610a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * This mode is used with {@link #seekTo(long, int)} to move media position to 12620a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * a sync (or key) frame associated with a data source that is located 12630a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * right after or at the given time. 12640a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 12650a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @see #seekTo(long, int) 12660a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 12670a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int SEEK_NEXT_SYNC = 0x01; 12680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 12690a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * This mode is used with {@link #seekTo(long, int)} to move media position to 12700a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * a sync (or key) frame associated with a data source that is located 12710a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * closest to (in time) or at the given time. 12720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 12730a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @see #seekTo(long, int) 12740a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 12750a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int SEEK_CLOSEST_SYNC = 0x02; 12760a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 12770a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * This mode is used with {@link #seekTo(long, int)} to move media position to 12780a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * a frame (not necessarily a key frame) associated with a data source that 12790a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * is located closest to or at the given time. 12800a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 12810a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @see #seekTo(long, int) 12820a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 12830a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int SEEK_CLOSEST = 0x03; 12840a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 12850a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** @hide */ 128669d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang @IntDef(flag = false, prefix = "SEEK", value = { 12870a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia SEEK_PREVIOUS_SYNC, 12880a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia SEEK_NEXT_SYNC, 12890a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia SEEK_CLOSEST_SYNC, 12900a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia SEEK_CLOSEST, 12910a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia }) 12920a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia @Retention(RetentionPolicy.SOURCE) 12930a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public @interface SeekMode {} 12940a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 12950a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 12960a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Moves the media to specified time position by considering the given mode. 12970a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 12980a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * When seekTo is finished, the user will be notified via OnSeekComplete supplied by the user. 12990a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * There is at most one active seekTo processed at any time. If there is a to-be-completed 13000a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * seekTo, new seekTo requests will be queued in such a way that only the last request 13010a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * is kept. When current seekTo is completed, the queued request will be processed if 13020a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * that request is different from just-finished seekTo operation, i.e., the requested 13030a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * position or mode is different. 13040a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 13050a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param msec the offset in milliseconds from the start to seek to. 13060a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * When seeking to the given time position, there is no guarantee that the data source 13070a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * has a frame located at the position. When this happens, a frame nearby will be rendered. 13080a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * If msec is negative, time position zero will be used. 13090a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * If msec is larger than duration, duration will be used. 13100a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param mode the mode indicating where exactly to seek to. 13110a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 1312d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 13130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract void seekTo(long msec, @SeekMode int mode); 13140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 13150a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 13160a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Get current playback position as a {@link MediaTimestamp}. 13170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 13180a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The MediaTimestamp represents how the media time correlates to the system time in 13190a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * a linear fashion using an anchor and a clock rate. During regular playback, the media 13200a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * time moves fairly constantly (though the anchor frame may be rebased to a current 13210a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * system time, the linear correlation stays steady). Therefore, this method does not 13220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * need to be called often. 13230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 13240a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * To help users get current playback position, this method always anchors the timestamp 13250a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * to the current {@link System#nanoTime system time}, so 13260a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link MediaTimestamp#getAnchorMediaTimeUs} can be used as current playback position. 13270a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 13280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @return a MediaTimestamp object if a timestamp is available, or {@code null} if no timestamp 13290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * is available, e.g. because the media player has not been initialized. 13300a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 13310a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @see MediaTimestamp 13320a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 13330a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia @Nullable 13340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract MediaTimestamp getTimestamp(); 13350a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 13360a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 13370a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Gets the media metadata. 13380a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 13390a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param update_only controls whether the full set of available 13400a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * metadata is returned or just the set that changed since the 13410a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * last call. See {@see #METADATA_UPDATE_ONLY} and {@see 13420a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * #METADATA_ALL}. 13430a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 13440a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param apply_filter if true only metadata that matches the 13450a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * filter is returned. See {@see #APPLY_METADATA_FILTER} and {@see 13460a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * #BYPASS_METADATA_FILTER}. 13470a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 13480a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @return The metadata, possibly empty. null if an error occured. 13490a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia // FIXME: unhide. 13500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@hide} 13510a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 13520a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public Metadata getMetadata(final boolean update_only, 13530a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia final boolean apply_filter) { 13540a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia return null; 13550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia } 13560a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 13570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 13580a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Set a filter for the metadata update notification and update 13590a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * retrieval. The caller provides 2 set of metadata keys, allowed 13600a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * and blocked. The blocked set always takes precedence over the 13610a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * allowed one. 13620a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Metadata.MATCH_ALL and Metadata.MATCH_NONE are 2 sets available as 13630a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * shorthands to allow/block all or no metadata. 13640a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 13650a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * By default, there is no filter set. 13660a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 13670a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param allow Is the set of metadata the client is interested 13680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * in receiving new notifications for. 13690a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param block Is the set of metadata the client is not interested 13700a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * in receiving new notifications for. 13710a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @return The call status code. 13720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 13730a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia // FIXME: unhide. 13740a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@hide} 13750a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 13760a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public int setMetadataFilter(Set<Integer> allow, Set<Integer> block) { 13770a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia return 0; 13780a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia } 13790a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 13800a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 13810a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Resets the MediaPlayer2 to its uninitialized state. After calling 13820a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * this method, you will have to initialize it again by setting the 13831789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * data source and calling prepare(). 13840a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 1385d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is a synchronous call. 1386de2bbb322bbeec45dfed89c3cc17ae0cc07c73b1Jaewan Kim @Override 13870a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract void reset(); 13880a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 13890a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 13900a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Set up a timer for {@link #TimeProvider}. {@link #TimeProvider} will be 13910a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * notified when the presentation time reaches (becomes greater than or equal to) 13920a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the value specified. 13930a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 13940a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param mediaTimeUs presentation time to get timed event callback at 13950a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 13960a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 13970a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public void notifyAt(long mediaTimeUs) { } 13980a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 13990a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 14000a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Checks whether the MediaPlayer2 is looping or non-looping. 14010a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 14020a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @return true if the MediaPlayer2 is currently looping, false otherwise 14030a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 14040a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 14050a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public boolean isLooping() { 14060a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia return false; 14070a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia } 14080a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 14090a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 14100a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Sets the audio session ID. 14110a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 14120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param sessionId the audio session ID. 14130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The audio session ID is a system wide unique identifier for the audio stream played by 14140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * this MediaPlayer2 instance. 14150a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The primary use of the audio session ID is to associate audio effects to a particular 14160a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * instance of MediaPlayer2: if an audio session ID is provided when creating an audio effect, 14170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * this effect will be applied only to the audio content of media players within the same 14180a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * audio session and not to the output mix. 14190a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * When created, a MediaPlayer2 instance automatically generates its own audio session ID. 14200a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * However, it is possible to force this player to be part of an already existing audio session 14210a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * by calling this method. 14220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * This method must be called before one of the overloaded <code> setDataSource </code> methods. 14230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 1424d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 14250a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract void setAudioSessionId(int sessionId); 14260a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 14270a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 14280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Returns the audio session ID. 14290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 14300a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @return the audio session ID. {@see #setAudioSessionId(int)} 14310a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Note that the audio session ID is 0 only if a problem occured when the MediaPlayer2 was contructed. 14320a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 14330a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract int getAudioSessionId(); 14340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 14350a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 14360a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Attaches an auxiliary effect to the player. A typical auxiliary effect is a reverberation 14370a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * effect which can be applied on any sound source that directs a certain amount of its 14380a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * energy to this effect. This amount is defined by setAuxEffectSendLevel(). 14390a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * See {@link #setAuxEffectSendLevel(float)}. 14400a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p>After creating an auxiliary effect (e.g. 14410a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link android.media.audiofx.EnvironmentalReverb}), retrieve its ID with 14420a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link android.media.audiofx.AudioEffect#getId()} and use it when calling this method 14430a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * to attach the player to the effect. 14440a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p>To detach the effect from the player, call this method with a null effect id. 14450a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p>This method must be called after one of the overloaded <code> setDataSource </code> 14460a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * methods. 14470a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param effectId system wide unique id of the effect to attach 14480a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 1449d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 14500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract void attachAuxEffect(int effectId); 14510a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 14520a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 14530a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 14540a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Sets the send level of the player to the attached auxiliary effect. 14550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * See {@link #attachAuxEffect(int)}. The level value range is 0 to 1.0. 14560a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p>By default the send level is 0, so even if an effect is attached to the player 14570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * this method must be called for the effect to be applied. 14580a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p>Note that the passed level value is a raw scalar. UI controls should be scaled 14590a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * logarithmically: the gain applied by audio framework ranges from -72dB to 0dB, 14600a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * so an appropriate conversion from linear UI input x to level is: 14610a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * x == 0 -> level = 0 14620a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 0 < x <= R -> level = 10^(72*(x-R)/20/R) 14630a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param level send level scalar 14640a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 1465d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 14660a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract void setAuxEffectSendLevel(float level); 14670a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 14680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 14690a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Class for MediaPlayer2 to return each audio/video/subtitle track's metadata. 14700a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 14710a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @see android.media.MediaPlayer2#getTrackInfo 14720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 14730a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract static class TrackInfo { 14740a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 14750a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Gets the track type. 14760a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @return TrackType which indicates if the track is video, audio, timed text. 14770a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 14780a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract int getTrackType(); 14790a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 14800a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 14810a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Gets the language code of the track. 14820a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @return a language code in either way of ISO-639-1 or ISO-639-2. 14830a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * When the language is unknown or could not be determined, 14840a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * ISO-639-2 language code, "und", is returned. 14850a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 14860a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract String getLanguage(); 14870a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 14880a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 14890a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Gets the {@link MediaFormat} of the track. If the format is 14900a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * unknown or could not be determined, null is returned. 14910a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 14920a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract MediaFormat getFormat(); 14930a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 14940a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_TRACK_TYPE_UNKNOWN = 0; 14950a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_TRACK_TYPE_VIDEO = 1; 14960a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_TRACK_TYPE_AUDIO = 2; 14970a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 14980a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** @hide */ 14990a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_TRACK_TYPE_TIMEDTEXT = 3; 15000a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 15010a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_TRACK_TYPE_SUBTITLE = 4; 15020a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_TRACK_TYPE_METADATA = 5; 15030a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 15040a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia @Override 15050a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract String toString(); 15060a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia }; 15070a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 15080a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 15090a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Returns a List of track information. 15100a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 15110a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @return List of track info. The total number of tracks is the array length. 15120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Must be called again if an external timed text source has been added after 15130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * addTimedTextSource method is called. 15140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 15150a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract List<TrackInfo> getTrackInfo(); 15160a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 15170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /* Do not change these values without updating their counterparts 15180a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * in include/media/stagefright/MediaDefs.h and media/libstagefright/MediaDefs.cpp! 15190a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 15200a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 15210a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * MIME type for SubRip (SRT) container. Used in addTimedTextSource APIs. 15220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 15230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 15240a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final String MEDIA_MIMETYPE_TEXT_SUBRIP = "application/x-subrip"; 15250a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 15260a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 15270a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * MIME type for WebVTT subtitle data. 15280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 15290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 15300a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final String MEDIA_MIMETYPE_TEXT_VTT = "text/vtt"; 15310a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 15320a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 15330a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * MIME type for CEA-608 closed caption data. 15340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 15350a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 15360a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final String MEDIA_MIMETYPE_TEXT_CEA_608 = "text/cea-608"; 15370a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 15380a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 15390a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * MIME type for CEA-708 closed caption data. 15400a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 15410a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 15420a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final String MEDIA_MIMETYPE_TEXT_CEA_708 = "text/cea-708"; 15430a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 15440a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** @hide */ 15450a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public void setSubtitleAnchor( 15460a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia SubtitleController controller, 15470a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia SubtitleController.Anchor anchor) { } 15480a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 15490a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** @hide */ 15500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia @Override 15510a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public void onSubtitleTrackSelected(SubtitleTrack track) { } 15520a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 15530a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** @hide */ 15540a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public void addSubtitleSource(InputStream is, MediaFormat format) { } 15550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 15560a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /* TODO: Limit the total number of external timed text source to a reasonable number. 15570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 15580a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 15590a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Adds an external timed text source file. 15600a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 15610a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Currently supported format is SubRip with the file extension .srt, case insensitive. 15620a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Note that a single external timed text source may contain multiple tracks in it. 15630a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * One can find the total number of available tracks using {@link #getTrackInfo()} to see what 15640a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * additional tracks become available after this method call. 15650a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 15660a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param path The file path of external timed text source file. 15670a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param mimeType The mime type of the file. Must be one of the mime types listed above. 15680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IOException if the file cannot be accessed or is corrupted. 15690a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IllegalArgumentException if the mimeType is not supported. 15700a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IllegalStateException if called in an invalid state. 15710a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 15720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 15730a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public void addTimedTextSource(String path, String mimeType) throws IOException { } 15740a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 15750a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 15760a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Adds an external timed text source file (Uri). 15770a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 15780a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Currently supported format is SubRip with the file extension .srt, case insensitive. 15790a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Note that a single external timed text source may contain multiple tracks in it. 15800a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * One can find the total number of available tracks using {@link #getTrackInfo()} to see what 15810a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * additional tracks become available after this method call. 15820a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 15830a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param context the Context to use when resolving the Uri 15840a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param uri the Content URI of the data you want to play 15850a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param mimeType The mime type of the file. Must be one of the mime types listed above. 15860a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IOException if the file cannot be accessed or is corrupted. 15870a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IllegalArgumentException if the mimeType is not supported. 15880a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IllegalStateException if called in an invalid state. 15890a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 15900a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 15910a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public void addTimedTextSource(Context context, Uri uri, String mimeType) throws IOException { } 15920a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 15930a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 15940a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Adds an external timed text source file (FileDescriptor). 15950a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 15960a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * It is the caller's responsibility to close the file descriptor. 15970a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * It is safe to do so as soon as this call returns. 15980a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 15990a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Currently supported format is SubRip. Note that a single external timed text source may 16000a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * contain multiple tracks in it. One can find the total number of available tracks 16010a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * using {@link #getTrackInfo()} to see what additional tracks become available 16020a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * after this method call. 16030a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 16040a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param fd the FileDescriptor for the file you want to play 16050a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param mimeType The mime type of the file. Must be one of the mime types listed above. 16060a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IllegalArgumentException if the mimeType is not supported. 16070a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IllegalStateException if called in an invalid state. 16080a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 16090a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 16100a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public void addTimedTextSource(FileDescriptor fd, String mimeType) { } 16110a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 16120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 16130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Adds an external timed text file (FileDescriptor). 16140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 16150a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * It is the caller's responsibility to close the file descriptor. 16160a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * It is safe to do so as soon as this call returns. 16170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 16180a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Currently supported format is SubRip. Note that a single external timed text source may 16190a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * contain multiple tracks in it. One can find the total number of available tracks 16200a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * using {@link #getTrackInfo()} to see what additional tracks become available 16210a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * after this method call. 16220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 16230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param fd the FileDescriptor for the file you want to play 16240a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param offset the offset into the file where the data to be played starts, in bytes 16250a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param length the length in bytes of the data to be played 16260a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param mime The mime type of the file. Must be one of the mime types listed above. 16270a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IllegalArgumentException if the mimeType is not supported. 16280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IllegalStateException if called in an invalid state. 16290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 16300a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 16310a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract void addTimedTextSource(FileDescriptor fd, long offset, long length, String mime); 16320a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 16330a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 16340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Returns the index of the audio, video, or subtitle track currently selected for playback, 16350a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The return value is an index into the array returned by {@link #getTrackInfo()}, and can 16360a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * be used in calls to {@link #selectTrack(int)} or {@link #deselectTrack(int)}. 16370a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 16380a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param trackType should be one of {@link TrackInfo#MEDIA_TRACK_TYPE_VIDEO}, 16390a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link TrackInfo#MEDIA_TRACK_TYPE_AUDIO}, or 16400a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link TrackInfo#MEDIA_TRACK_TYPE_SUBTITLE} 16410a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @return index of the audio, video, or subtitle track currently selected for playback; 16420a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * a negative integer is returned when there is no selected track for {@code trackType} or 16430a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * when {@code trackType} is not one of audio, video, or subtitle. 16440a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IllegalStateException if called after {@link #close()} 16450a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 16460a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @see #getTrackInfo() 16470a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @see #selectTrack(int) 16480a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @see #deselectTrack(int) 16490a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 16500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract int getSelectedTrack(int trackType); 16510a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 16520a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 16530a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Selects a track. 16540a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 16550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * If a MediaPlayer2 is in invalid state, it throws an IllegalStateException exception. 16560a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * If a MediaPlayer2 is in <em>Started</em> state, the selected track is presented immediately. 16570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * If a MediaPlayer2 is not in Started state, it just marks the track to be played. 16580a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </p> 16590a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 16600a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * In any valid state, if it is called multiple times on the same type of track (ie. Video, 16610a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Audio, Timed Text), the most recent one will be chosen. 16620a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </p> 16630a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 16640a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The first audio and video tracks are selected by default if available, even though 16650a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * this method is not called. However, no timed text track will be selected until 16660a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * this function is called. 16670a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </p> 16680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 16690a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Currently, only timed text tracks or audio tracks can be selected via this method. 16700a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * In addition, the support for selecting an audio track at runtime is pretty limited 16710a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * in that an audio track can only be selected in the <em>Prepared</em> state. 16720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </p> 16730a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param index the index of the track to be selected. The valid range of the index 16740a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * is 0..total number of track - 1. The total number of tracks as well as the type of 16750a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * each individual track can be found by calling {@link #getTrackInfo()} method. 16760a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IllegalStateException if called in an invalid state. 16770a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 16780a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @see android.media.MediaPlayer2#getTrackInfo 16790a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 1680d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 16810a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract void selectTrack(int index); 16820a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 16830a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 16840a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Deselect a track. 16850a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 16860a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Currently, the track must be a timed text track and no audio or video tracks can be 16870a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * deselected. If the timed text track identified by index has not been 16880a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * selected before, it throws an exception. 16890a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * </p> 16900a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param index the index of the track to be deselected. The valid range of the index 16910a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * is 0..total number of tracks - 1. The total number of tracks as well as the type of 16920a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * each individual track can be found by calling {@link #getTrackInfo()} method. 16930a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IllegalStateException if called in an invalid state. 16940a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 16950a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @see android.media.MediaPlayer2#getTrackInfo 16960a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 1697d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 16980a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract void deselectTrack(int index); 16990a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 17000a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** @hide */ 17010a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public MediaTimeProvider getMediaTimeProvider() { 17020a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia return null; 17030a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia } 17040a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 17050a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 17060a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Interface definition for callbacks to be invoked when the player has the corresponding 17070a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * events. 17080a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 17091789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract static class MediaPlayer2EventCallback { 17100a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 17110a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Called to indicate the video size 17120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 17130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The video size (width and height) could be 0 if there was no video, 17140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * no display surface was set, or the value was not determined yet. 17150a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 17160a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param mp the MediaPlayer2 associated with this callback 17171789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param dsd the DataSourceDesc of this data source 17180a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param width the width of the video 17190a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param height the height of the video 17200a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 17211789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public void onVideoSizeChanged(MediaPlayer2 mp, DataSourceDesc dsd, int width, int height) { } 17220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 17230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 17240a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Called to indicate an avaliable timed text 17250a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 17260a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param mp the MediaPlayer2 associated with this callback 17271789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param dsd the DataSourceDesc of this data source 17280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param text the timed text sample which contains the text 17290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * needed to be displayed and the display format. 17300a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 17310a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 17321789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public void onTimedText(MediaPlayer2 mp, DataSourceDesc dsd, TimedText text) { } 17330a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 17340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 17350a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Called to indicate avaliable timed metadata 17360a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 17370a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * This method will be called as timed metadata is extracted from the media, 17380a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * in the same order as it occurs in the media. The timing of this event is 17390a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * not controlled by the associated timestamp. 17400a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 17410a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Currently only HTTP live streaming data URI's embedded with timed ID3 tags generates 17420a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link TimedMetaData}. 17430a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 17440a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @see MediaPlayer2#selectTrack(int) 17450a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @see MediaPlayer2.OnTimedMetaDataAvailableListener 17460a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @see TimedMetaData 17470a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 17480a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param mp the MediaPlayer2 associated with this callback 17491789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param dsd the DataSourceDesc of this data source 17500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param data the timed metadata sample associated with this event 17510a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 175269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public void onTimedMetaDataAvailable( 175369d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MediaPlayer2 mp, DataSourceDesc dsd, TimedMetaData data) { } 17540a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 17550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 17560a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Called to indicate an error. 17570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 17580a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param mp the MediaPlayer2 the error pertains to 17591789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param dsd the DataSourceDesc of this data source 176069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @param what the type of error that has occurred. 17610a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param extra an extra code, specific to the error. Typically 17620a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * implementation dependent. 17630a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 176469d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public void onError( 176569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MediaPlayer2 mp, DataSourceDesc dsd, @MediaError int what, int extra) { } 17660a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 17670a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 17680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Called to indicate an info or a warning. 17690a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 17700a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param mp the MediaPlayer2 the info pertains to. 17711789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param dsd the DataSourceDesc of this data source 17720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param what the type of info or warning. 17730a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param extra an extra code, specific to the info. Typically 17740a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * implementation dependent. 17750a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 177669d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public void onInfo(MediaPlayer2 mp, DataSourceDesc dsd, @MediaInfo int what, int extra) { } 17771789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 17781789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 17791789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Called to acknowledge an API call. 17801789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * 17811789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param mp the MediaPlayer2 the call was made on. 17821789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param dsd the DataSourceDesc of this data source 17831789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param what the enum for the API call. 17841789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param status the returned status code for the call. 17851789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 178669d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public void onCallCompleted( 178769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MediaPlayer2 mp, DataSourceDesc dsd, @CallCompleted int what, 178869d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang @CallStatus int status) { } 17891789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 17901789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 17911789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Called to indicate media clock has changed. 17921789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * 17931789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param mp the MediaPlayer2 the media time pertains to. 17941789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param dsd the DataSourceDesc of this data source 17951789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param timestamp the new media clock. 17961789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 179769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public void onMediaTimeChanged( 179869d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MediaPlayer2 mp, DataSourceDesc dsd, MediaTimestamp timestamp) { } 17991789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 18001789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 18011789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Called to indicate {@link #notifyWhenCommandLabelReached(Object)} has been processed. 18021789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * 18031789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param mp the MediaPlayer2 {@link #notifyWhenCommandLabelReached(Object)} was called on. 18041789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param label the application specific Object given by 18051789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@link #notifyWhenCommandLabelReached(Object)}. 18061789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 180769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public void onCommandLabelReached(MediaPlayer2 mp, @NonNull Object label) { } 18080a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia } 18090a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 18100a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 18111789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Sets the callback to be invoked when the media source is ready for playback. 18120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 18130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param eventCallback the callback that will be run 18140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param executor the executor through which the callback should be invoked 18150a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 1816d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is a synchronous call. 18171789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void setMediaPlayer2EventCallback(@NonNull @CallbackExecutor Executor executor, 18181789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @NonNull MediaPlayer2EventCallback eventCallback); 18190a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 18200a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 18211789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Clears the {@link MediaPlayer2EventCallback}. 18220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 1823d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is a synchronous call. 18241789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void clearMediaPlayer2EventCallback(); 18250a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 18260a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 18270a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Interface definition of a callback to be invoked when a 18280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * track has data available. 18290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 18300a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 18310a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 18320a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public interface OnSubtitleDataListener 18330a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia { 18340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public void onSubtitleData(MediaPlayer2 mp, SubtitleData data); 18350a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia } 18360a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 18370a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 18380a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Register a callback to be invoked when a track has data available. 18390a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 18400a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param listener the callback that will be run 18410a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 18420a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 18430a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 1844d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is a synchronous call. 18450a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public void setOnSubtitleDataListener(OnSubtitleDataListener listener) { } 18460a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 18470a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 18480a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /* Do not change these values without updating their counterparts 18490a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * in include/media/mediaplayer2.h! 18500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 18510a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** Unspecified media player error. 18521789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onError 18530a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 18540a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_ERROR_UNKNOWN = 1; 18550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 18560a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** The video is streamed and its container is not valid for progressive 18570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * playback i.e the video's index (e.g moov atom) is not at the start of the 18580a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * file. 18591789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onError 18600a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 18610a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK = 200; 18620a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 18630a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** File or network related operation errors. */ 18640a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_ERROR_IO = -1004; 18650a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** Bitstream is not conforming to the related coding standard or file spec. */ 18660a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_ERROR_MALFORMED = -1007; 18670a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** Bitstream is conforming to the related coding standard or file spec, but 18680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the media framework does not support the feature. */ 18690a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_ERROR_UNSUPPORTED = -1010; 18700a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** Some operation takes too long to complete, usually more than 3-5 seconds. */ 18710a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_ERROR_TIMED_OUT = -110; 18720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 18730a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** Unspecified low-level system error. This value originated from UNKNOWN_ERROR in 18740a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * system/core/include/utils/Errors.h 18751789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onError 18760a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 18770a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 18780a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_ERROR_SYSTEM = -2147483648; 18790a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 188069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang /** 188169d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @hide 188269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang */ 188369d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang @IntDef(flag = false, prefix = "MEDIA_ERROR", value = { 188469d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_ERROR_UNKNOWN, 188569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK, 188669d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_ERROR_IO, 188769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_ERROR_MALFORMED, 188869d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_ERROR_UNSUPPORTED, 188969d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_ERROR_TIMED_OUT, 189069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_ERROR_SYSTEM 189169d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang }) 189269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang @Retention(RetentionPolicy.SOURCE) 189369d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public @interface MediaError {} 18940a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 18950a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /* Do not change these values without updating their counterparts 18960a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * in include/media/mediaplayer2.h! 18970a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 18980a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** Unspecified media player info. 18991789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onInfo 19000a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 19010a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_INFO_UNKNOWN = 1; 19020a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 19030a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** The player switched to this datas source because it is the 19041789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * next-to-be-played in the playlist. 19051789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onInfo 19060a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 19070a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_INFO_STARTED_AS_NEXT = 2; 19080a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 19090a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** The player just pushed the very first video frame for rendering. 19101789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onInfo 19110a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 19120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_INFO_VIDEO_RENDERING_START = 3; 19130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 19140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** The player just rendered the very first audio sample. 19151789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onInfo 19160a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 19170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_INFO_AUDIO_RENDERING_START = 4; 19180a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 19190a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** The player just completed the playback of this data source. 19201789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onInfo 19210a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 19220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_INFO_PLAYBACK_COMPLETE = 5; 19230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 19241789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** The player just completed the playback of the full playlist. 19251789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onInfo 19260a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 19270a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_INFO_PLAYLIST_END = 6; 19280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 19290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** The player just prepared a data source. 19301789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onInfo 19310a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 19320a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_INFO_PREPARED = 100; 19330a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 19340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** The video is too complex for the decoder: it can't decode frames fast 19350a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * enough. Possibly only the audio plays fine at this stage. 19361789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onInfo 19370a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 19380a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_INFO_VIDEO_TRACK_LAGGING = 700; 19390a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 19400a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** MediaPlayer2 is temporarily pausing playback internally in order to 19410a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * buffer more data. 19421789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onInfo 19430a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 19440a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_INFO_BUFFERING_START = 701; 19450a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 19460a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** MediaPlayer2 is resuming playback after filling buffers. 19471789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onInfo 19480a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 19490a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_INFO_BUFFERING_END = 702; 19500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 19510a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** Estimated network bandwidth information (kbps) is available; currently this event fires 19520a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * simultaneously as {@link #MEDIA_INFO_BUFFERING_START} and {@link #MEDIA_INFO_BUFFERING_END} 19530a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * when playing network files. 19541789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onInfo 19550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 19560a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 19570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_INFO_NETWORK_BANDWIDTH = 703; 19580a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 19591789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 19601789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Update status in buffering a media source received through progressive downloading. 19611789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * The received buffering percentage indicates how much of the content has been buffered 19621789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * or played. For example a buffering update of 80 percent when half the content 19631789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * has already been played indicates that the next 30 percent of the 19641789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * content to play has been buffered. 19651789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * 19661789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * The {@code extra} parameter in {@code MediaPlayer2EventCallback.onInfo} is the 19671789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * percentage (0-100) of the content that has been buffered or played thus far. 19681789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onInfo 19691789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 19701789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public static final int MEDIA_INFO_BUFFERING_UPDATE = 704; 19711789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 19720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** Bad interleaving means that a media has been improperly interleaved or 19730a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * not interleaved at all, e.g has all the video samples first then all the 19740a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * audio ones. Video is playing but a lot of disk seeks may be happening. 19751789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onInfo 19760a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 19770a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_INFO_BAD_INTERLEAVING = 800; 19780a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 19790a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** The media cannot be seeked (e.g live stream) 19801789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onInfo 19810a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 19820a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_INFO_NOT_SEEKABLE = 801; 19830a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 19840a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** A new set of metadata is available. 19851789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onInfo 19860a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 19870a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_INFO_METADATA_UPDATE = 802; 19880a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 19890a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** A new set of external-only metadata is available. Used by 19900a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * JAVA framework to avoid triggering track scanning. 19910a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @hide 19920a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 19930a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_INFO_EXTERNAL_METADATA_UPDATE = 803; 19940a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 19950a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** Informs that audio is not playing. Note that playback of the video 19960a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * is not interrupted. 19971789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onInfo 19980a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 19990a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_INFO_AUDIO_NOT_PLAYING = 804; 20000a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 20010a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** Informs that video is not playing. Note that playback of the audio 20020a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * is not interrupted. 20031789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onInfo 20040a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 20050a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_INFO_VIDEO_NOT_PLAYING = 805; 20060a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 20070a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** Failed to handle timed text track properly. 20081789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onInfo 20090a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 20100a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@hide} 20110a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 20120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_INFO_TIMED_TEXT_ERROR = 900; 20130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 20140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** Subtitle track was not supported by the media framework. 20151789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onInfo 20160a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 20170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_INFO_UNSUPPORTED_SUBTITLE = 901; 20180a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 20190a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** Reading the subtitle track takes too long. 20201789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onInfo 20210a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 20220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int MEDIA_INFO_SUBTITLE_TIMED_OUT = 902; 20230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 202469d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang /** 202569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @hide 202669d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang */ 202769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang @IntDef(flag = false, prefix = "MEDIA_INFO", value = { 202869d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_UNKNOWN, 202969d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_STARTED_AS_NEXT, 203069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_VIDEO_RENDERING_START, 203169d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_AUDIO_RENDERING_START, 203269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_PLAYBACK_COMPLETE, 203369d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_PLAYLIST_END, 203469d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_PREPARED, 203569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_VIDEO_TRACK_LAGGING, 203669d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_BUFFERING_START, 203769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_BUFFERING_END, 203869d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_NETWORK_BANDWIDTH, 203969d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_BUFFERING_UPDATE, 204069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_BAD_INTERLEAVING, 204169d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_NOT_SEEKABLE, 204269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_METADATA_UPDATE, 204369d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_EXTERNAL_METADATA_UPDATE, 204469d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_AUDIO_NOT_PLAYING, 204569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_VIDEO_NOT_PLAYING, 204669d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_TIMED_TEXT_ERROR, 204769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_UNSUPPORTED_SUBTITLE, 204869d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MEDIA_INFO_SUBTITLE_TIMED_OUT 204969d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang }) 205069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang @Retention(RetentionPolicy.SOURCE) 205169d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public @interface MediaInfo {} 205269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang 20531789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia //-------------------------------------------------------------------------- 2054d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #attachAuxEffect}. 205569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 20561789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 205769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_ATTACH_AUX_EFFECT = 1; 20581789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2059d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #deselectTrack}. 206069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 20611789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 206269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_DESELECT_TRACK = 2; 20631789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2064d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #loopCurrent}. 206569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 20661789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 206769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_LOOP_CURRENT = 3; 20681789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2069d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #pause}. 207069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 20711789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 207269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_PAUSE = 4; 20731789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2074d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #play}. 207569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 20761789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 207769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_PLAY = 5; 20781789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2079d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #prepare}. 208069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 20811789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 208269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_PREPARE = 6; 20831789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2084d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #releaseDrm}. 208569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 20861789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 208769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_RELEASE_DRM = 12; 20881789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2089d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #restoreDrmKeys}. 209069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 20911789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 209269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_RESTORE_DRM_KEYS = 13; 20931789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2094d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #seekTo}. 209569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 20961789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 209769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_SEEK_TO = 14; 20981789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2099d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #selectTrack}. 210069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 21011789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 210269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_SELECT_TRACK = 15; 21031789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2104d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #setAudioAttributes}. 210569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 21061789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 210769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_SET_AUDIO_ATTRIBUTES = 16; 21081789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2109d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #setAudioSessionId}. 211069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 21111789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 211269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_SET_AUDIO_SESSION_ID = 17; 21131789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2114d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #setAuxEffectSendLevel}. 211569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 21161789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 211769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_SET_AUX_EFFECT_SEND_LEVEL = 18; 21181789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2119d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #setDataSource}. 212069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 21211789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 212269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_SET_DATA_SOURCE = 19; 21231789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2124d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #setNextDataSource}. 212569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 21261789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 212769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_SET_NEXT_DATA_SOURCE = 22; 21281789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2129d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #setNextDataSources}. 213069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 21311789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 213269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_SET_NEXT_DATA_SOURCES = 23; 21331789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2134d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #setPlaybackParams}. 213569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 21361789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 213769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_SET_PLAYBACK_PARAMS = 24; 21381789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2139d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #setPlaybackSpeed}. 214069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 21411789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 214269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_SET_PLAYBACK_SPEED = 25; 21431789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2144d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #setPlayerVolume}. 214569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 21461789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 214769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_SET_PLAYER_VOLUME = 26; 21481789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2149d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #setSurface}. 215069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 21511789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 215269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_SET_SURFACE = 27; 21531789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2154d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #setSyncParams}. 215569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 21561789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 215769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_SET_SYNC_PARAMS = 28; 21581789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2159d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #skipToNext}. 216069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 21611789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 216269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_SKIP_TO_NEXT = 29; 21631789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 2164d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia /** The player just completed a call {@link #setBufferingParams}. 216569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 2166d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia * @hide 2167d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia */ 216869d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_SET_BUFFERING_PARAMS = 1001; 2169d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia 217069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang /** The player just completed a call {@code setVideoScalingMode}. 217169d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 2172d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia * @hide 2173d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia */ 217469d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_SET_VIDEO_SCALING_MODE = 1002; 2175d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia 217669d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang /** The player just completed a call {@code notifyWhenCommandLabelReached}. 217769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCommandLabelReached 217869d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @hide 217969d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang */ 218069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_COMPLETED_NOTIFY_WHEN_COMMAND_LABEL_REACHED = 1003; 218169d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang 218269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang /** 218369d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @hide 218469d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang */ 218569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang @IntDef(flag = false, prefix = "CALL_COMPLETED", value = { 218669d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_ATTACH_AUX_EFFECT, 218769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_DESELECT_TRACK, 218869d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_LOOP_CURRENT, 218969d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_PAUSE, 219069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_PLAY, 219169d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_PREPARE, 219269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_RELEASE_DRM, 219369d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_RESTORE_DRM_KEYS, 219469d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_SEEK_TO, 219569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_SELECT_TRACK, 219669d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_SET_AUDIO_ATTRIBUTES, 219769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_SET_AUDIO_SESSION_ID, 219869d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_SET_AUX_EFFECT_SEND_LEVEL, 219969d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_SET_DATA_SOURCE, 220069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_SET_NEXT_DATA_SOURCE, 220169d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_SET_NEXT_DATA_SOURCES, 220269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_SET_PLAYBACK_PARAMS, 220369d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_SET_PLAYBACK_SPEED, 220469d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_SET_PLAYER_VOLUME, 220569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_SET_SURFACE, 220669d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_SET_SYNC_PARAMS, 220769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_SKIP_TO_NEXT, 220869d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_SET_BUFFERING_PARAMS, 220969d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_SET_VIDEO_SCALING_MODE, 221069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_COMPLETED_NOTIFY_WHEN_COMMAND_LABEL_REACHED 221169d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang }) 221269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang @Retention(RetentionPolicy.SOURCE) 221369d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public @interface CallCompleted {} 221469d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang 221569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang /** Status code represents that call is completed without an error. 221669d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 221769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang */ 221869d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_STATUS_NO_ERROR = 0; 221969d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang 222069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang /** Status code represents that call is ended with an unknown error. 222169d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 222269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang */ 222369d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_STATUS_ERROR_UNKNOWN = Integer.MIN_VALUE; 222469d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang 222569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang /** Status code represents that the player is not in valid state for the operation. 222669d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 222769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang */ 222869d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_STATUS_INVALID_OPERATION = 1; 222969d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang 223069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang /** Status code represents that the argument is illegal. 223169d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 223269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang */ 223369d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_STATUS_BAD_VALUE = 2; 223469d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang 223569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang /** Status code represents that the operation is not allowed. 223669d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 223769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang */ 223869d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_STATUS_PERMISSION_DENIED = 3; 223969d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang 224069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang /** Status code represents a file or network related operation error. 224169d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 224269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang */ 224369d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_STATUS_ERROR_IO = 4; 224469d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang 224569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang /** Status code represents that DRM operation is called before preparing a DRM scheme through 224669d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * {@link #prepareDrm}. 224769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @see android.media.MediaPlayer2.MediaPlayer2EventCallback#onCallCompleted 224869d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang */ 224969d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public static final int CALL_STATUS_NO_DRM_SCHEME = 5; 225069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang 225169d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang /** 225269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @hide 225369d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang */ 225469d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang @IntDef(flag = false, prefix = "CALL_STATUS", value = { 225569d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_STATUS_NO_ERROR, 225669d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_STATUS_ERROR_UNKNOWN, 225769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_STATUS_INVALID_OPERATION, 225869d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_STATUS_BAD_VALUE, 225969d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_STATUS_PERMISSION_DENIED, 226069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_STATUS_ERROR_IO, 226169d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang CALL_STATUS_NO_DRM_SCHEME}) 226269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang @Retention(RetentionPolicy.SOURCE) 226369d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public @interface CallStatus {} 22640a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 22650a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia // Modular DRM begin 22660a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 22670a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 22680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Interface definition of a callback to be invoked when the app 22690a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * can do DRM configuration (get/set properties) before the session 22700a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * is opened. This facilitates configuration of the properties, like 22710a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 'securityLevel', which has to be set after DRM scheme creation but 22720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * before the DRM session is opened. 22730a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 2274d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia * The only allowed DRM calls in this listener are {@link #getDrmPropertyString} 2275d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia * and {@link #setDrmPropertyString}. 22760a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 22770a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public interface OnDrmConfigHelper 22780a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia { 22790a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 22800a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Called to give the app the opportunity to configure DRM before the session is created 22810a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 22820a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param mp the {@code MediaPlayer2} associated with this callback 22831789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param dsd the DataSourceDesc of this data source 22840a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 22851789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public void onDrmConfig(MediaPlayer2 mp, DataSourceDesc dsd); 22860a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia } 22870a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 22880a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 22890a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Register a callback to be invoked for configuration of the DRM object before 22900a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the session is created. 22910a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The callback will be invoked synchronously during the execution 22920a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * of {@link #prepareDrm(UUID uuid)}. 22930a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 22940a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param listener the callback that will be run 22950a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 2296d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is a synchronous call. 22970a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract void setOnDrmConfigHelper(OnDrmConfigHelper listener); 22980a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 22990a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 23000a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Interface definition for callbacks to be invoked when the player has the corresponding 23010a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * DRM events. 23020a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 23030a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract static class DrmEventCallback { 23040a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 23050a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Called to indicate DRM info is available 23060a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 2307128875996598b9cfa91bad137d3a73dfcb4a2aedWei Jia * @param mp the {@code MediaPlayer2} associated with this callback 23081789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param dsd the DataSourceDesc of this data source 2309128875996598b9cfa91bad137d3a73dfcb4a2aedWei Jia * @param drmInfo DRM info of the source including PSSH, and subset 2310128875996598b9cfa91bad137d3a73dfcb4a2aedWei Jia * of crypto schemes supported by this device 23110a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 23121789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public void onDrmInfo(MediaPlayer2 mp, DataSourceDesc dsd, DrmInfo drmInfo) { } 23130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 23140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 2315d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia * Called to notify the client that {@link #prepareDrm} is finished and ready for 23161789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * key request/response. 23170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 2318128875996598b9cfa91bad137d3a73dfcb4a2aedWei Jia * @param mp the {@code MediaPlayer2} associated with this callback 23191789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * @param dsd the DataSourceDesc of this data source 232069d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang * @param status the result of DRM preparation. 23210a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 232269d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang public void onDrmPrepared( 232369d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang MediaPlayer2 mp, DataSourceDesc dsd, @PrepareDrmStatusCode int status) { } 23240a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia } 23250a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 23260a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 23271789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Sets the callback to be invoked when the media source is ready for playback. 23280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 23290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param eventCallback the callback that will be run 23300a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param executor the executor through which the callback should be invoked 23310a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 2332d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is a synchronous call. 23331789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void setDrmEventCallback(@NonNull @CallbackExecutor Executor executor, 23340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia @NonNull DrmEventCallback eventCallback); 23350a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 23360a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 23371789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * Clears the {@link DrmEventCallback}. 23380a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 2339d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is a synchronous call. 23401789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void clearDrmEventCallback(); 23410a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 23420a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 23430a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The status codes for {@link DrmEventCallback#onDrmPrepared} listener. 23440a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 23450a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 23460a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * DRM preparation has succeeded. 23470a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 23480a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int PREPARE_DRM_STATUS_SUCCESS = 0; 23490a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 23500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 23510a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The device required DRM provisioning but couldn't reach the provisioning server. 23520a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 23530a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int PREPARE_DRM_STATUS_PROVISIONING_NETWORK_ERROR = 1; 23540a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 23550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 23560a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The device required DRM provisioning but the provisioning server denied the request. 23570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 23580a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int PREPARE_DRM_STATUS_PROVISIONING_SERVER_ERROR = 2; 23590a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 23600a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 23610a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The DRM preparation has failed . 23620a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 23630a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final int PREPARE_DRM_STATUS_PREPARATION_ERROR = 3; 23640a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 23650a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 23660a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** @hide */ 236769d2d51a59ecb30742673fbe56b68397185a08c5Dongwon Kang @IntDef(flag = false, prefix = "PREPARE_DRM_STATUS", value = { 23680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia PREPARE_DRM_STATUS_SUCCESS, 23690a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia PREPARE_DRM_STATUS_PROVISIONING_NETWORK_ERROR, 23700a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia PREPARE_DRM_STATUS_PROVISIONING_SERVER_ERROR, 23710a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia PREPARE_DRM_STATUS_PREPARATION_ERROR, 23720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia }) 23730a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia @Retention(RetentionPolicy.SOURCE) 23740a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public @interface PrepareDrmStatusCode {} 23750a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 23760a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 23770a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Retrieves the DRM Info associated with the current source 23780a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 23790a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IllegalStateException if called before being prepared 23800a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 23810a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract DrmInfo getDrmInfo(); 23820a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 23830a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 23840a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Prepares the DRM for the current source 23850a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 2386d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia * If {@link OnDrmConfigHelper} is registered, it will be called during 23870a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * preparation to allow configuration of the DRM properties before opening the 23880a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * DRM session. Note that the callback is called synchronously in the thread that called 2389d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia * {@link #prepareDrm}. It should be used only for a series of {@code getDrmPropertyString} 23900a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * and {@code setDrmPropertyString} calls and refrain from any lengthy operation. 23910a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 23920a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * If the device has not been provisioned before, this call also provisions the device 23930a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * which involves accessing the provisioning server and can take a variable time to 23940a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * complete depending on the network connectivity. 23950a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * If {@code OnDrmPreparedListener} is registered, prepareDrm() runs in non-blocking 23960a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * mode by launching the provisioning in the background and returning. The listener 23970a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * will be called when provisioning and preparation has finished. If a 23980a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@code OnDrmPreparedListener} is not registered, prepareDrm() waits till provisioning 23990a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * and preparation has finished, i.e., runs in blocking mode. 24000a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 24010a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * If {@code OnDrmPreparedListener} is registered, it is called to indicate the DRM 24020a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * session being ready. The application should not make any assumption about its call 24030a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * sequence (e.g., before or after prepareDrm returns), or the thread context that will 24040a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * execute the listener (unless the listener is registered with a handler thread). 24050a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 24060a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 24070a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param uuid The UUID of the crypto scheme. If not known beforehand, it can be retrieved 24080a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * from the source through {@code getDrmInfo} or registering a {@code onDrmInfoListener}. 24090a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 24100a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws IllegalStateException if called before being prepared or the DRM was 24110a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * prepared already 24120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws UnsupportedSchemeException if the crypto scheme is not supported 24130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws ResourceBusyException if required DRM resources are in use 24140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws ProvisioningNetworkErrorException if provisioning is required but failed due to a 24150a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * network error 24160a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws ProvisioningServerErrorException if provisioning is required but failed due to 24170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the request denied by the provisioning server 24180a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 2419d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is a synchronous call. 24200a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract void prepareDrm(@NonNull UUID uuid) 24210a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia throws UnsupportedSchemeException, ResourceBusyException, 24220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia ProvisioningNetworkErrorException, ProvisioningServerErrorException; 24230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 24240a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 24250a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Releases the DRM session 24260a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 24270a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The player has to have an active DRM session and be in stopped, or prepared 24280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * state before this call is made. 24290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * A {@code reset()} call will release the DRM session implicitly. 24300a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 24310a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws NoDrmSchemeException if there is no active DRM session to release 24320a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 2433d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 24340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract void releaseDrm() throws NoDrmSchemeException; 24350a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 24360a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 24370a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * A key request/response exchange occurs between the app and a license server 24380a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * to obtain or release keys used to decrypt encrypted content. 24390a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 24401789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * getDrmKeyRequest() is used to obtain an opaque key request byte array that is 24410a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * delivered to the license server. The opaque key request byte array is returned 24420a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * in KeyRequest.data. The recommended URL to deliver the key request to is 24430a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * returned in KeyRequest.defaultUrl. 24440a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 24450a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * After the app has received the key request response from the server, 24460a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * it should deliver to the response to the DRM engine plugin using the method 24471789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@link #provideDrmKeyResponse}. 24480a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 24490a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param keySetId is the key-set identifier of the offline keys being released when keyType is 24500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link MediaDrm#KEY_TYPE_RELEASE}. It should be set to null for other key requests, when 24510a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * keyType is {@link MediaDrm#KEY_TYPE_STREAMING} or {@link MediaDrm#KEY_TYPE_OFFLINE}. 24520a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 24530a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param initData is the container-specific initialization data when the keyType is 24540a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link MediaDrm#KEY_TYPE_STREAMING} or {@link MediaDrm#KEY_TYPE_OFFLINE}. Its meaning is 24550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * interpreted based on the mime type provided in the mimeType parameter. It could 24560a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * contain, for example, the content ID, key ID or other data obtained from the content 24570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * metadata that is required in generating the key request. 24580a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * When the keyType is {@link MediaDrm#KEY_TYPE_RELEASE}, it should be set to null. 24590a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 24600a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param mimeType identifies the mime type of the content 24610a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 24620a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param keyType specifies the type of the request. The request may be to acquire 24630a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * keys for streaming, {@link MediaDrm#KEY_TYPE_STREAMING}, or for offline content 24640a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link MediaDrm#KEY_TYPE_OFFLINE}, or to release previously acquired 24650a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * keys ({@link MediaDrm#KEY_TYPE_RELEASE}), which are identified by a keySetId. 24660a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 24670a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param optionalParameters are included in the key request message to 24680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * allow a client application to provide additional message parameters to the server. 24690a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * This may be {@code null} if no additional parameters are to be sent. 24700a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 24710a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws NoDrmSchemeException if there is no active DRM session 24720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 24730a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia @NonNull 24741789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract MediaDrm.KeyRequest getDrmKeyRequest( 24751789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Nullable byte[] keySetId, @Nullable byte[] initData, 24760a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia @Nullable String mimeType, @MediaDrm.KeyType int keyType, 24770a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia @Nullable Map<String, String> optionalParameters) 24780a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia throws NoDrmSchemeException; 24790a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 24800a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 24810a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * A key response is received from the license server by the app, then it is 24821789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * provided to the DRM engine plugin using provideDrmKeyResponse. When the 24830a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * response is for an offline key request, a key-set identifier is returned that 24840a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * can be used to later restore the keys to a new session with the method 24851789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * {@ link # restoreDrmKeys}. 24860a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * When the response is for a streaming or release request, null is returned. 24870a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 24880a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param keySetId When the response is for a release request, keySetId identifies 24890a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * the saved key associated with the release request (i.e., the same keySetId 24901789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * passed to the earlier {@ link # getDrmKeyRequest} call. It MUST be null when the 24910a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * response is for either streaming or offline key requests. 24920a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 24930a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param response the byte array response from the server 24940a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 24950a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws NoDrmSchemeException if there is no active DRM session 24960a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @throws DeniedByServerException if the response indicates that the 24970a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * server rejected the request 24980a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 2499d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is a synchronous call. 25001789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract byte[] provideDrmKeyResponse( 25011789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @Nullable byte[] keySetId, @NonNull byte[] response) 25020a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia throws NoDrmSchemeException, DeniedByServerException; 25030a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 25040a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 25050a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Restore persisted offline keys into a new session. keySetId identifies the 25061789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia * keys to load, obtained from a prior call to {@link #provideDrmKeyResponse}. 25070a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 25080a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param keySetId identifies the saved key set to restore 25090a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 2510d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is an asynchronous call. 25111789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void restoreDrmKeys(@NonNull byte[] keySetId) 25120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia throws NoDrmSchemeException; 25130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 25140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 25150a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Read a DRM engine plugin String property value, given the property name string. 25160a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 25170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param propertyName the property name 25180a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 25190a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Standard fields names are: 25200a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link MediaDrm#PROPERTY_VENDOR}, {@link MediaDrm#PROPERTY_VERSION}, 25210a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link MediaDrm#PROPERTY_DESCRIPTION}, {@link MediaDrm#PROPERTY_ALGORITHMS} 25220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 25230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia @NonNull 25241789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract String getDrmPropertyString( 25251789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @NonNull @MediaDrm.StringProperty String propertyName) 25260a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia throws NoDrmSchemeException; 25270a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 25280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 25290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Set a DRM engine plugin String property value. 25300a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * <p> 25310a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param propertyName the property name 25320a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * @param value the property value 25330a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * 25340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Standard fields names are: 25350a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link MediaDrm#PROPERTY_VENDOR}, {@link MediaDrm#PROPERTY_VERSION}, 25360a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * {@link MediaDrm#PROPERTY_DESCRIPTION}, {@link MediaDrm#PROPERTY_ALGORITHMS} 25370a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 2538d526bc3b886b4127c310f5dea0035404e28d27a2Wei Jia // This is a synchronous call. 25391789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public abstract void setDrmPropertyString( 25401789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia @NonNull @MediaDrm.StringProperty String propertyName, @NonNull String value) 25410a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia throws NoDrmSchemeException; 25420a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 25430a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 25440a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Encapsulates the DRM properties of the source. 25450a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 25460a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract static class DrmInfo { 25470a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 25480a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Returns the PSSH info of the data source for each supported DRM scheme. 25490a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 25500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract Map<UUID, byte[]> getPssh(); 25510a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 25520a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 25530a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Returns the intersection of the data source and the device DRM schemes. 25540a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * It effectively identifies the subset of the source's DRM schemes which 25550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * are supported by the device too. 25560a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 25570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract List<UUID> getSupportedSchemes(); 25580a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia }; // DrmInfo 25590a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 25600a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 25610a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Thrown when a DRM method is called before preparing a DRM scheme through prepareDrm(). 25620a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Extends MediaDrm.MediaDrmException 25630a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 25640a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract static class NoDrmSchemeException extends MediaDrmException { 25650a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia protected NoDrmSchemeException(String detailMessage) { 25660a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia super(detailMessage); 25670a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia } 25680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia } 25690a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 25700a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 25710a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Thrown when the device requires DRM provisioning but the provisioning attempt has 25720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * failed due to a network error (Internet reachability, timeout, etc.). 25730a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Extends MediaDrm.MediaDrmException 25740a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 25750a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract static class ProvisioningNetworkErrorException extends MediaDrmException { 25760a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia protected ProvisioningNetworkErrorException(String detailMessage) { 25770a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia super(detailMessage); 25780a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia } 25790a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia } 25800a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 25810a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 25820a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Thrown when the device requires DRM provisioning but the provisioning attempt has 25830a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * failed due to the provisioning server denying the request. 25840a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Extends MediaDrm.MediaDrmException 25850a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 25860a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public abstract static class ProvisioningServerErrorException extends MediaDrmException { 25870a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia protected ProvisioningServerErrorException(String detailMessage) { 25880a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia super(detailMessage); 25890a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia } 25900a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia } 25910a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 25920a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final class MetricsConstants { 25930a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia private MetricsConstants() {} 25940a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 25950a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 25960a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Key to extract the MIME type of the video track 25970a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * from the {@link MediaPlayer2#getMetrics} return value. 25980a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The value is a String. 25990a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 26000a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final String MIME_TYPE_VIDEO = "android.media.mediaplayer.video.mime"; 26010a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 26020a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 26030a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Key to extract the codec being used to decode the video track 26040a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * from the {@link MediaPlayer2#getMetrics} return value. 26050a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The value is a String. 26060a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 26070a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final String CODEC_VIDEO = "android.media.mediaplayer.video.codec"; 26080a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 26090a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 26100a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Key to extract the width (in pixels) of the video track 26110a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * from the {@link MediaPlayer2#getMetrics} return value. 26120a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The value is an integer. 26130a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 26140a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final String WIDTH = "android.media.mediaplayer.width"; 26150a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 26160a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 26170a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Key to extract the height (in pixels) of the video track 26180a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * from the {@link MediaPlayer2#getMetrics} return value. 26190a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The value is an integer. 26200a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 26210a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final String HEIGHT = "android.media.mediaplayer.height"; 26220a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 26230a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 26240a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Key to extract the count of video frames played 26250a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * from the {@link MediaPlayer2#getMetrics} return value. 26260a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The value is an integer. 26270a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 26280a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final String FRAMES = "android.media.mediaplayer.frames"; 26290a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 26300a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 26310a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Key to extract the count of video frames dropped 26320a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * from the {@link MediaPlayer2#getMetrics} return value. 26330a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The value is an integer. 26340a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 26350a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final String FRAMES_DROPPED = "android.media.mediaplayer.dropped"; 26360a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 26370a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 26380a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Key to extract the MIME type of the audio track 26390a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * from the {@link MediaPlayer2#getMetrics} return value. 26400a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The value is a String. 26410a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 26420a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final String MIME_TYPE_AUDIO = "android.media.mediaplayer.audio.mime"; 26430a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 26440a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 26450a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Key to extract the codec being used to decode the audio track 26460a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * from the {@link MediaPlayer2#getMetrics} return value. 26470a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The value is a String. 26480a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 26490a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final String CODEC_AUDIO = "android.media.mediaplayer.audio.codec"; 26500a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 26510a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 26520a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Key to extract the duration (in milliseconds) of the 26530a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * media being played 26540a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * from the {@link MediaPlayer2#getMetrics} return value. 26550a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The value is a long. 26560a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 26570a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final String DURATION = "android.media.mediaplayer.durationMs"; 26580a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 26590a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 26600a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Key to extract the playing time (in milliseconds) of the 26610a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * media being played 26620a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * from the {@link MediaPlayer2#getMetrics} return value. 26630a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The value is a long. 26640a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 26650a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final String PLAYING = "android.media.mediaplayer.playingMs"; 26660a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 26670a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 26680a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Key to extract the count of errors encountered while 26690a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * playing the media 26700a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * from the {@link MediaPlayer2#getMetrics} return value. 26710a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The value is an integer. 26720a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 26730a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final String ERRORS = "android.media.mediaplayer.err"; 26740a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 26750a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia /** 26760a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * Key to extract an (optional) error code detected while 26770a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * playing the media 26780a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * from the {@link MediaPlayer2#getMetrics} return value. 26790a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia * The value is an integer. 26800a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia */ 26810a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia public static final String ERROR_CODE = "android.media.mediaplayer.errcode"; 26820a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia 26830a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia } 26841789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 26851789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 26861789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia Constant to retrieve only the new metadata since the last 26871789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia call. 26881789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia // FIXME: unhide. 26891789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia // FIXME: add link to getMetadata(boolean, boolean) 26901789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia {@hide} 26911789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 26921789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public static final boolean METADATA_UPDATE_ONLY = true; 26931789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 26941789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 26951789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia Constant to retrieve all the metadata. 26961789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia // FIXME: unhide. 26971789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia // FIXME: add link to getMetadata(boolean, boolean) 26981789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia {@hide} 26991789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 27001789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public static final boolean METADATA_ALL = false; 27011789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 27021789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 27031789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia Constant to enable the metadata filter during retrieval. 27041789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia // FIXME: unhide. 27051789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia // FIXME: add link to getMetadata(boolean, boolean) 27061789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia {@hide} 27071789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 27081789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public static final boolean APPLY_METADATA_FILTER = true; 27091789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 27101789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia /** 27111789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia Constant to disable the metadata filter during retrieval. 27121789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia // FIXME: unhide. 27131789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia // FIXME: add link to getMetadata(boolean, boolean) 27141789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia {@hide} 27151789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia */ 27161789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia public static final boolean BYPASS_METADATA_FILTER = false; 27171789cc7f8221fd1f682fa08a1aeb1e37c2315887Wei Jia 27180a8a8f0b26634395ce64123e2a385670d6b07c00Wei Jia} 2719