Loading media/java/android/media/MediaPlayer.java +26 −42 Original line number Original line Diff line number Diff line Loading @@ -158,18 +158,10 @@ import java.util.concurrent.Executor; * the user supplied callback method OnErrorListener.onError() will be * the user supplied callback method OnErrorListener.onError() will be * invoked by the internal player engine and the object will be * invoked by the internal player engine and the object will be * transfered to the <em>Error</em> state. </li> * transfered to the <em>Error</em> state. </li> * <li>It is also recommended that once * <li>You must call {@link #release()} once you have finished using an instance to release * a MediaPlayer object is no longer being used, call {@link #release()} immediately * acquired resources, such as memory and codecs. Once you have called {@link #release}, you * so that resources used by the internal player engine associated with the * must no longer interact with the released instance. * MediaPlayer object can be released immediately. Resource may include * <li>MediaPlayer objects created using <code>new</code> is in the * singleton resources such as hardware acceleration components and * failure to call {@link #release()} may cause subsequent instances of * MediaPlayer objects to fallback to software implementations or fail * altogether. Once the MediaPlayer * object is in the <em>End</em> state, it can no longer be used and * there is no way to bring it back to any other state. </li> * <li>Furthermore, * the MediaPlayer objects created using <code>new</code> is in the * <em>Idle</em> state, while those created with one * <em>Idle</em> state, while those created with one * of the overloaded convenient <code>create</code> methods are <em>NOT</em> * of the overloaded convenient <code>create</code> methods are <em>NOT</em> * in the <em>Idle</em> state. In fact, the objects are in the <em>Prepared</em> * in the <em>Idle</em> state. In fact, the objects are in the <em>Prepared</em> Loading Loading @@ -407,7 +399,7 @@ import java.util.concurrent.Executor; * <tr><td>release </p></td> * <tr><td>release </p></td> * <td>any </p></td> * <td>any </p></td> * <td>{} </p></td> * <td>{} </p></td> * <td>After {@link #release()}, the object is no longer available. </p></td></tr> * <td>After {@link #release()}, you must not interact with the object. </p></td></tr> * <tr><td>reset </p></td> * <tr><td>reset </p></td> * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, * PlaybackCompleted, Error}</p></td> * PlaybackCompleted, Error}</p></td> Loading Loading @@ -657,11 +649,13 @@ public class MediaPlayer extends PlayerBase private ProvisioningThread mDrmProvisioningThread; private ProvisioningThread mDrmProvisioningThread; /** /** * Default constructor. Consider using one of the create() methods for * Default constructor. * synchronously instantiating a MediaPlayer from a Uri or resource. * * <p>When done with the MediaPlayer, you should call {@link #release()}, * <p>Consider using one of the create() methods for synchronously instantiating a MediaPlayer * to free the resources. If not released, too many MediaPlayer instances may * from a Uri or resource. * result in an exception.</p> * * <p>You must call {@link #release()} when you are finished using the instantiated instance. * Doing so frees any resources you have previously acquired. */ */ public MediaPlayer() { public MediaPlayer() { this(AudioSystem.AUDIO_SESSION_ALLOCATE); this(AudioSystem.AUDIO_SESSION_ALLOCATE); Loading Loading @@ -873,9 +867,10 @@ public class MediaPlayer extends PlayerBase /** /** * Convenience method to create a MediaPlayer for a given Uri. * Convenience method to create a MediaPlayer for a given Uri. * On success, {@link #prepare()} will already have been called and must not be called again. * On success, {@link #prepare()} will already have been called and must not be called again. * <p>When done with the MediaPlayer, you should call {@link #release()}, * * to free the resources. If not released, too many MediaPlayer instances will * <p>You must call {@link #release()} when you are finished using the created instance. Doing * result in an exception.</p> * so frees any resources you have previously acquired. * * <p>Note that since {@link #prepare()} is called automatically in this method, * <p>Note that since {@link #prepare()} is called automatically in this method, * you cannot change the audio * you cannot change the audio * session ID (see {@link #setAudioSessionId(int)}) or audio attributes * session ID (see {@link #setAudioSessionId(int)}) or audio attributes Loading @@ -892,9 +887,10 @@ public class MediaPlayer extends PlayerBase /** /** * Convenience method to create a MediaPlayer for a given Uri. * Convenience method to create a MediaPlayer for a given Uri. * On success, {@link #prepare()} will already have been called and must not be called again. * On success, {@link #prepare()} will already have been called and must not be called again. * <p>When done with the MediaPlayer, you should call {@link #release()}, * * to free the resources. If not released, too many MediaPlayer instances will * <p>You must call {@link #release()} when you are finished using the created instance. Doing * result in an exception.</p> * so frees any resources you have previously acquired. * * <p>Note that since {@link #prepare()} is called automatically in this method, * <p>Note that since {@link #prepare()} is called automatically in this method, * you cannot change the audio * you cannot change the audio * session ID (see {@link #setAudioSessionId(int)}) or audio attributes * session ID (see {@link #setAudioSessionId(int)}) or audio attributes Loading Loading @@ -955,9 +951,10 @@ public class MediaPlayer extends PlayerBase /** /** * Convenience method to create a MediaPlayer for a given resource id. * Convenience method to create a MediaPlayer for a given resource id. * On success, {@link #prepare()} will already have been called and must not be called again. * On success, {@link #prepare()} will already have been called and must not be called again. * <p>When done with the MediaPlayer, you should call {@link #release()}, * * to free the resources. If not released, too many MediaPlayer instances will * <p>You must call {@link #release()} when you are finished using the created instance. Doing * result in an exception.</p> * so frees any resources you have previously acquired. * * <p>Note that since {@link #prepare()} is called automatically in this method, * <p>Note that since {@link #prepare()} is called automatically in this method, * you cannot change the audio * you cannot change the audio * session ID (see {@link #setAudioSessionId(int)}) or audio attributes * session ID (see {@link #setAudioSessionId(int)}) or audio attributes Loading Loading @@ -2157,21 +2154,8 @@ public class MediaPlayer extends PlayerBase /** /** * Releases resources associated with this MediaPlayer object. * Releases resources associated with this MediaPlayer object. * It is considered good practice to call this method when you're * * done using the MediaPlayer. In particular, whenever an Activity * <p>You must call this method once the instance is no longer required. * of an application is paused (its onPause() method is called), * or stopped (its onStop() method is called), this method should be * invoked to release the MediaPlayer object, unless the application * has a special need to keep the object around. In addition to * unnecessary resources (such as memory and instances of codecs) * being held, failure to call this method immediately if a * MediaPlayer object is no longer needed may also lead to * continuous battery consumption for mobile devices, and playback * failure for other applications if no multiple instances of the * same codec are supported on a device. Even if multiple instances * of the same codec are supported, some performance degradation * may be expected when unnecessary multiple instances are used * at the same time. */ */ public void release() { public void release() { baseRelease(); baseRelease(); Loading Loading
media/java/android/media/MediaPlayer.java +26 −42 Original line number Original line Diff line number Diff line Loading @@ -158,18 +158,10 @@ import java.util.concurrent.Executor; * the user supplied callback method OnErrorListener.onError() will be * the user supplied callback method OnErrorListener.onError() will be * invoked by the internal player engine and the object will be * invoked by the internal player engine and the object will be * transfered to the <em>Error</em> state. </li> * transfered to the <em>Error</em> state. </li> * <li>It is also recommended that once * <li>You must call {@link #release()} once you have finished using an instance to release * a MediaPlayer object is no longer being used, call {@link #release()} immediately * acquired resources, such as memory and codecs. Once you have called {@link #release}, you * so that resources used by the internal player engine associated with the * must no longer interact with the released instance. * MediaPlayer object can be released immediately. Resource may include * <li>MediaPlayer objects created using <code>new</code> is in the * singleton resources such as hardware acceleration components and * failure to call {@link #release()} may cause subsequent instances of * MediaPlayer objects to fallback to software implementations or fail * altogether. Once the MediaPlayer * object is in the <em>End</em> state, it can no longer be used and * there is no way to bring it back to any other state. </li> * <li>Furthermore, * the MediaPlayer objects created using <code>new</code> is in the * <em>Idle</em> state, while those created with one * <em>Idle</em> state, while those created with one * of the overloaded convenient <code>create</code> methods are <em>NOT</em> * of the overloaded convenient <code>create</code> methods are <em>NOT</em> * in the <em>Idle</em> state. In fact, the objects are in the <em>Prepared</em> * in the <em>Idle</em> state. In fact, the objects are in the <em>Prepared</em> Loading Loading @@ -407,7 +399,7 @@ import java.util.concurrent.Executor; * <tr><td>release </p></td> * <tr><td>release </p></td> * <td>any </p></td> * <td>any </p></td> * <td>{} </p></td> * <td>{} </p></td> * <td>After {@link #release()}, the object is no longer available. </p></td></tr> * <td>After {@link #release()}, you must not interact with the object. </p></td></tr> * <tr><td>reset </p></td> * <tr><td>reset </p></td> * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, * PlaybackCompleted, Error}</p></td> * PlaybackCompleted, Error}</p></td> Loading Loading @@ -657,11 +649,13 @@ public class MediaPlayer extends PlayerBase private ProvisioningThread mDrmProvisioningThread; private ProvisioningThread mDrmProvisioningThread; /** /** * Default constructor. Consider using one of the create() methods for * Default constructor. * synchronously instantiating a MediaPlayer from a Uri or resource. * * <p>When done with the MediaPlayer, you should call {@link #release()}, * <p>Consider using one of the create() methods for synchronously instantiating a MediaPlayer * to free the resources. If not released, too many MediaPlayer instances may * from a Uri or resource. * result in an exception.</p> * * <p>You must call {@link #release()} when you are finished using the instantiated instance. * Doing so frees any resources you have previously acquired. */ */ public MediaPlayer() { public MediaPlayer() { this(AudioSystem.AUDIO_SESSION_ALLOCATE); this(AudioSystem.AUDIO_SESSION_ALLOCATE); Loading Loading @@ -873,9 +867,10 @@ public class MediaPlayer extends PlayerBase /** /** * Convenience method to create a MediaPlayer for a given Uri. * Convenience method to create a MediaPlayer for a given Uri. * On success, {@link #prepare()} will already have been called and must not be called again. * On success, {@link #prepare()} will already have been called and must not be called again. * <p>When done with the MediaPlayer, you should call {@link #release()}, * * to free the resources. If not released, too many MediaPlayer instances will * <p>You must call {@link #release()} when you are finished using the created instance. Doing * result in an exception.</p> * so frees any resources you have previously acquired. * * <p>Note that since {@link #prepare()} is called automatically in this method, * <p>Note that since {@link #prepare()} is called automatically in this method, * you cannot change the audio * you cannot change the audio * session ID (see {@link #setAudioSessionId(int)}) or audio attributes * session ID (see {@link #setAudioSessionId(int)}) or audio attributes Loading @@ -892,9 +887,10 @@ public class MediaPlayer extends PlayerBase /** /** * Convenience method to create a MediaPlayer for a given Uri. * Convenience method to create a MediaPlayer for a given Uri. * On success, {@link #prepare()} will already have been called and must not be called again. * On success, {@link #prepare()} will already have been called and must not be called again. * <p>When done with the MediaPlayer, you should call {@link #release()}, * * to free the resources. If not released, too many MediaPlayer instances will * <p>You must call {@link #release()} when you are finished using the created instance. Doing * result in an exception.</p> * so frees any resources you have previously acquired. * * <p>Note that since {@link #prepare()} is called automatically in this method, * <p>Note that since {@link #prepare()} is called automatically in this method, * you cannot change the audio * you cannot change the audio * session ID (see {@link #setAudioSessionId(int)}) or audio attributes * session ID (see {@link #setAudioSessionId(int)}) or audio attributes Loading Loading @@ -955,9 +951,10 @@ public class MediaPlayer extends PlayerBase /** /** * Convenience method to create a MediaPlayer for a given resource id. * Convenience method to create a MediaPlayer for a given resource id. * On success, {@link #prepare()} will already have been called and must not be called again. * On success, {@link #prepare()} will already have been called and must not be called again. * <p>When done with the MediaPlayer, you should call {@link #release()}, * * to free the resources. If not released, too many MediaPlayer instances will * <p>You must call {@link #release()} when you are finished using the created instance. Doing * result in an exception.</p> * so frees any resources you have previously acquired. * * <p>Note that since {@link #prepare()} is called automatically in this method, * <p>Note that since {@link #prepare()} is called automatically in this method, * you cannot change the audio * you cannot change the audio * session ID (see {@link #setAudioSessionId(int)}) or audio attributes * session ID (see {@link #setAudioSessionId(int)}) or audio attributes Loading Loading @@ -2157,21 +2154,8 @@ public class MediaPlayer extends PlayerBase /** /** * Releases resources associated with this MediaPlayer object. * Releases resources associated with this MediaPlayer object. * It is considered good practice to call this method when you're * * done using the MediaPlayer. In particular, whenever an Activity * <p>You must call this method once the instance is no longer required. * of an application is paused (its onPause() method is called), * or stopped (its onStop() method is called), this method should be * invoked to release the MediaPlayer object, unless the application * has a special need to keep the object around. In addition to * unnecessary resources (such as memory and instances of codecs) * being held, failure to call this method immediately if a * MediaPlayer object is no longer needed may also lead to * continuous battery consumption for mobile devices, and playback * failure for other applications if no multiple instances of the * same codec are supported on a device. Even if multiple instances * of the same codec are supported, some performance degradation * may be expected when unnecessary multiple instances are used * at the same time. */ */ public void release() { public void release() { baseRelease(); baseRelease(); Loading