Loading media/java/android/media/MediaPlayer2.java +47 −159 Original line number Diff line number Diff line Loading @@ -23,9 +23,7 @@ import android.annotation.Nullable; import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.graphics.SurfaceTexture; import android.net.Uri; import android.os.Handler; import android.os.Parcel; import android.os.PersistableBundle; import android.view.Surface; import android.view.SurfaceHolder; Loading @@ -34,7 +32,6 @@ import dalvik.system.CloseGuard; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.UUID; Loading Loading @@ -241,47 +238,6 @@ public abstract class MediaPlayer2 implements AutoCloseable return new MediaPlayer2Impl(context); } private static final String[] decodeMediaPlayer2Uri(String location) { Uri uri = Uri.parse(location); if (!"mediaplayer2".equals(uri.getScheme())) { return new String[] {location}; } List<String> uris = uri.getQueryParameters("uri"); if (uris.isEmpty()) { return new String[] {location}; } List<String> keys = uri.getQueryParameters("key"); List<String> values = uri.getQueryParameters("value"); if (keys.size() != values.size()) { return new String[] {uris.get(0)}; } List<String> ls = new ArrayList(); ls.add(uris.get(0)); for (int i = 0; i < keys.size() ; i++) { ls.add(keys.get(i)); ls.add(values.get(i)); } return ls.toArray(new String[ls.size()]); } private static final String encodeMediaPlayer2Uri(String uri, String[] keys, String[] values) { Uri.Builder builder = new Uri.Builder(); builder.scheme("mediaplayer2").path("/").appendQueryParameter("uri", uri); if (keys == null || values == null || keys.length != values.length) { return builder.build().toString(); } for (int i = 0; i < keys.length ; i++) { builder .appendQueryParameter("key", keys[i]) .appendQueryParameter("value", values[i]); } return builder.build().toString(); } /** * @hide */ Loading @@ -290,12 +246,6 @@ public abstract class MediaPlayer2 implements AutoCloseable mGuard.open("close"); } /** * Returns a {@link MediaPlayerBase} implementation which runs based on * this MediaPlayer2 instance. */ public abstract MediaPlayerBase getMediaPlayerBase(); /** * Releases the resources held by this {@code MediaPlayer2} object. * Loading Loading @@ -342,8 +292,7 @@ public abstract class MediaPlayer2 implements AutoCloseable * Starts or resumes playback. If playback had previously been paused, * playback will continue from where it was paused. If playback had * reached end of stream and been paused, or never started before, * playback will start at the beginning. If the source had not been * prepared, the player will prepare the source and play. * playback will start at the beginning. * * @return a token which can be used to cancel the operation later with {@link #cancel}. */ Loading Loading @@ -404,9 +353,8 @@ public abstract class MediaPlayer2 implements AutoCloseable /** * Gets the current buffered media source position received through progressive downloading. * The received buffering percentage indicates how much of the content has been buffered * or played. For example a buffering update of 80 percent when half the content * has already been played indicates that the next 30 percent of the * For example a buffering update of 8000 milliseconds when 5000 milliseconds of the content * has already been played indicates that the next 3000 milliseconds of the * content to play has been buffered. * * @return the current buffered media source position in milliseconds Loading @@ -416,7 +364,6 @@ public abstract class MediaPlayer2 implements AutoCloseable /** * MediaPlayer2 has not been prepared or just has been reset. * In this state, MediaPlayer2 doesn't fetch data. * @hide */ public static final int PLAYER_STATE_IDLE = 1001; Loading @@ -424,26 +371,23 @@ public abstract class MediaPlayer2 implements AutoCloseable * MediaPlayer2 has been just prepared. * In this state, MediaPlayer2 just fetches data from media source, * but doesn't actively render data. * @hide */ public static final int PLAYER_STATE_PREPARED = 1002; /** * MediaPlayer2 is paused. * In this state, MediaPlayer2 doesn't actively render data. * @hide * In this state, MediaPlayer2 has allocated resources to construct playback * pipeline, but it doesn't actively render data. */ public static final int PLAYER_STATE_PAUSED = 1003; /** * MediaPlayer2 is actively playing back data. * @hide */ public static final int PLAYER_STATE_PLAYING = 1004; /** * MediaPlayer2 has hit some fatal error and cannot continue playback. * @hide */ public static final int PLAYER_STATE_ERROR = 1005; Loading @@ -469,7 +413,7 @@ public abstract class MediaPlayer2 implements AutoCloseable /** * Sets the audio attributes for this MediaPlayer2. * See {@link AudioAttributes} for how to build and configure an instance of this class. * You must call this method before {@link #prepare()} in order * You must call this method before {@link #play()} and {@link #pause()} in order * for the audio attributes to become effective thereafter. * @param attributes a non-null set of audio attributes * @return a token which can be used to cancel the operation later with {@link #cancel}. Loading Loading @@ -547,7 +491,7 @@ public abstract class MediaPlayer2 implements AutoCloseable public abstract Object setPlayerVolume(float volume); /** * Returns the current volume of this player to this player. * Returns the current volume of this player. * Note that it does not take into account the associated stream volume. * @return the player volume. */ Loading @@ -560,25 +504,10 @@ public abstract class MediaPlayer2 implements AutoCloseable return 1.0f; } /** * Create a request parcel which can be routed to the native media * player using {@link #invoke(Parcel, Parcel)}. The Parcel * returned has the proper InterfaceToken set. The caller should * not overwrite that token, i.e it can only append data to the * Parcel. * * @return A parcel suitable to hold a request for the native * player. * {@hide} */ public Parcel newRequest() { return null; } /** * Insert a task in the command queue to help the client to identify whether a batch * of commands has been finished. When this command is processed, a notification * {@code EventCallback.onCommandLabelReached} will be fired with the * {@link EventCallback#onCommandLabelReached onCommandLabelReached} will be fired with the * given {@code label}. * * @see EventCallback#onCommandLabelReached Loading @@ -601,10 +530,7 @@ public abstract class MediaPlayer2 implements AutoCloseable * played. * * @param sh the SurfaceHolder to use for video display * @throws IllegalStateException if the internal player engine has not been * initialized or has been released. * @return a token which can be used to cancel the operation later with {@link #cancel}. * @hide */ public abstract Object setDisplay(SurfaceHolder sh); Loading @@ -624,56 +550,44 @@ public abstract class MediaPlayer2 implements AutoCloseable * * @param surface The {@link Surface} to be used for the video portion of * the media. * @throws IllegalStateException if the internal player engine has not been * initialized or has been released. * @return a token which can be used to cancel the operation later with {@link #cancel}. */ // This is an asynchronous call. public abstract Object setSurface(Surface surface); /* Do not change these video scaling mode values below without updating * their counterparts in system/window.h! Please do not forget to update * {@link #isVideoScalingModeSupported} when new video scaling modes * are added. */ /** * Specifies a video scaling mode. The content is stretched to the * surface rendering area. When the surface has the same aspect ratio * as the content, the aspect ratio of the content is maintained; * otherwise, the aspect ratio of the content is not maintained when video * is being rendered. * There is no content cropping with this video scaling mode. */ public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT = 1; /** * Specifies a video scaling mode. The content is scaled, maintaining * its aspect ratio. The whole surface area is always used. When the * aspect ratio of the content is the same as the surface, no content * is cropped; otherwise, content is cropped to fit the surface. * @hide * Set the low-level power management behavior for this MediaPlayer2. This * can be used when the MediaPlayer2 is not playing through a SurfaceHolder * set with {@link #setDisplay(SurfaceHolder)} and thus can use the * high-level {@link #setScreenOnWhilePlaying(boolean)} feature. * * <p>This function has the MediaPlayer2 access the low-level power manager * service to control the device's power usage while playing is occurring. * The parameter is a combination of {@link android.os.PowerManager} wake flags. * Use of this method requires {@link android.Manifest.permission#WAKE_LOCK} * permission. * By default, no attempt is made to keep the device awake during playback. * * @param context the Context to use * @param mode the power/wake mode to set * @return a token which can be used to cancel the operation later with {@link #cancel}. * @see android.os.PowerManager */ public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING = 2; // This is an asynchronous call. public abstract Object setWakeMode(Context context, int mode); /** * Sets video scaling mode. To make the target video scaling mode * effective during playback, this method must be called after * data source is set. If not called, the default video * scaling mode is {@link #VIDEO_SCALING_MODE_SCALE_TO_FIT}. * * <p> The supported video scaling modes are: * <ul> * <li> {@link #VIDEO_SCALING_MODE_SCALE_TO_FIT} * </ul> * Control whether we should use the attached SurfaceHolder to keep the * screen on while video playback is occurring. This is the preferred * method over {@link #setWakeMode} where possible, since it doesn't * require that the application have permission for low-level wake lock * access. * * @param mode target video scaling mode. Must be one of the supported * video scaling modes; otherwise, IllegalArgumentException will be thrown. * @param screenOn Supply true to keep the screen on, false to allow it to turn off. * @return a token which can be used to cancel the operation later with {@link #cancel}. * * @see MediaPlayer2#VIDEO_SCALING_MODE_SCALE_TO_FIT * @hide */ public abstract Object setVideoScalingMode(int mode); // This is an asynchronous call. public abstract Object setScreenOnWhilePlaying(boolean screenOn); /** * Cancels a pending command. Loading Loading @@ -702,7 +616,7 @@ public abstract class MediaPlayer2 implements AutoCloseable * @return true if succesful, false if the specified {@link AudioDeviceInfo} is non-null and * does not correspond to a valid audio device. */ // This is an asynchronous call. // This is a synchronous call. @Override public abstract boolean setPreferredDevice(AudioDeviceInfo deviceInfo); Loading Loading @@ -746,36 +660,6 @@ public abstract class MediaPlayer2 implements AutoCloseable public abstract void removeOnRoutingChangedListener( AudioRouting.OnRoutingChangedListener listener); /** * Set the low-level power management behavior for this MediaPlayer2. * * <p>This function has the MediaPlayer2 access the low-level power manager * service to control the device's power usage while playing is occurring. * The parameter is a combination of {@link android.os.PowerManager} wake flags. * Use of this method requires {@link android.Manifest.permission#WAKE_LOCK} * permission. * By default, no attempt is made to keep the device awake during playback. * * @param context the Context to use * @param mode the power/wake mode to set * @see android.os.PowerManager * @hide */ public abstract void setWakeMode(Context context, int mode); /** * Control whether we should use the attached SurfaceHolder to keep the * screen on while video playback is occurring. This is the preferred * method over {@link #setWakeMode} where possible, since it doesn't * require that the application have permission for low-level wake lock * access. * * @param screenOn Supply true to keep the screen on, false to allow it * to turn off. * @hide */ public abstract void setScreenOnWhilePlaying(boolean screenOn); /** * Returns the width of the video. * Loading Loading @@ -1719,17 +1603,20 @@ public abstract class MediaPlayer2 implements AutoCloseable */ public static final int CALL_COMPLETED_SET_BUFFERING_PARAMS = 31; /** The player just completed a call {@link #setVideoScalingMode}. /** The player just completed a call {@link #setDisplay}. * @see EventCallback#onCallCompleted */ public static final int CALL_COMPLETED_SET_DISPLAY = 33; /** The player just completed a call {@link #setWakeMode}. * @see EventCallback#onCallCompleted * @hide */ public static final int CALL_COMPLETED_SET_VIDEO_SCALING_MODE = 32; public static final int CALL_COMPLETED_SET_WAKE_MODE = 34; /** The player just completed a call {@link #setDisplay}. /** The player just completed a call {@link #setScreenOnWhilePlaying}. * @see EventCallback#onCallCompleted * @hide */ public static final int CALL_COMPLETED_SET_DISPLAY = 33; public static final int CALL_COMPLETED_SET_SCREEN_ON_WHILE_PLAYING = 35; /** * The start of the methods which have separate call complete callback. Loading Loading @@ -1776,8 +1663,9 @@ public abstract class MediaPlayer2 implements AutoCloseable CALL_COMPLETED_SKIP_TO_NEXT, CALL_COMPLETED_CLEAR_NEXT_DATA_SOURCES, CALL_COMPLETED_SET_BUFFERING_PARAMS, CALL_COMPLETED_SET_VIDEO_SCALING_MODE, CALL_COMPLETED_SET_DISPLAY, CALL_COMPLETED_SET_WAKE_MODE, CALL_COMPLETED_SET_SCREEN_ON_WHILE_PLAYING, CALL_COMPLETED_NOTIFY_WHEN_COMMAND_LABEL_REACHED, CALL_COMPLETED_PREPARE_DRM, }) Loading media/java/android/media/MediaPlayer2Impl.java +86 −364 File changed.Preview size limit exceeded, changes collapsed. Show changes media/jni/android_media_MediaPlayer2.cpp +3 −18 Original line number Diff line number Diff line Loading @@ -893,20 +893,6 @@ android_media_MediaPlayer2_reset(JNIEnv *env, jobject thiz) process_media_player_call( env, thiz, mp->reset(), NULL, NULL ); } static jint android_media_MediaPlayer2_getAudioStreamType(JNIEnv *env, jobject thiz) { sp<MediaPlayer2> mp = getMediaPlayer(env, thiz); if (mp == NULL ) { jniThrowException(env, "java/lang/IllegalStateException", NULL); return 0; } audio_stream_type_t streamtype; process_media_player_call( env, thiz, mp->getAudioStreamType(&streamtype), NULL, NULL ); ALOGV("getAudioStreamType: %d (streamtype)", streamtype); return (jint) streamtype; } static jboolean android_media_MediaPlayer2_setParameter(JNIEnv *env, jobject thiz, jint key, jobject) { Loading Loading @@ -1467,7 +1453,7 @@ static const JNINativeMethod gMethods[] = { (void *)android_media_MediaPlayer2_handleDataSourceCallback }, {"nativePlayNextDataSource", "(J)V", (void *)android_media_MediaPlayer2_playNextDataSource}, {"_setVideoSurface", "(Landroid/view/Surface;)V", (void *)android_media_MediaPlayer2_setVideoSurface}, {"native_setVideoSurface", "(Landroid/view/Surface;)V", (void *)android_media_MediaPlayer2_setVideoSurface}, {"getBufferingParams", "()Landroid/media/BufferingParams;", (void *)android_media_MediaPlayer2_getBufferingParams}, {"_setBufferingParams", "(Landroid/media/BufferingParams;)V", (void *)android_media_MediaPlayer2_setBufferingParams}, {"_prepare", "()V", (void *)android_media_MediaPlayer2_prepare}, Loading @@ -1487,13 +1473,12 @@ static const JNINativeMethod gMethods[] = { {"getDuration", "()J", (void *)android_media_MediaPlayer2_getDuration}, {"_release", "()V", (void *)android_media_MediaPlayer2_release}, {"_reset", "()V", (void *)android_media_MediaPlayer2_reset}, {"_getAudioStreamType", "()I", (void *)android_media_MediaPlayer2_getAudioStreamType}, {"setParameter", "(ILjava/lang/Object;)Z", (void *)android_media_MediaPlayer2_setParameter}, {"getParameter", "(I)Ljava/lang/Object;", (void *)android_media_MediaPlayer2_getParameter}, {"setLooping", "(Z)V", (void *)android_media_MediaPlayer2_setLooping}, {"isLooping", "()Z", (void *)android_media_MediaPlayer2_isLooping}, {"_setVolume", "(F)V", (void *)android_media_MediaPlayer2_setVolume}, {"_invoke", "([B)[B", (void *)android_media_MediaPlayer2_invoke}, {"native_setVolume", "(F)V", (void *)android_media_MediaPlayer2_setVolume}, {"native_invoke", "([B)[B", (void *)android_media_MediaPlayer2_invoke}, {"native_init", "()V", (void *)android_media_MediaPlayer2_native_init}, {"native_setup", "(Ljava/lang/Object;)V", (void *)android_media_MediaPlayer2_native_setup}, {"native_finalize", "()V", (void *)android_media_MediaPlayer2_native_finalize}, Loading Loading
media/java/android/media/MediaPlayer2.java +47 −159 Original line number Diff line number Diff line Loading @@ -23,9 +23,7 @@ import android.annotation.Nullable; import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.graphics.SurfaceTexture; import android.net.Uri; import android.os.Handler; import android.os.Parcel; import android.os.PersistableBundle; import android.view.Surface; import android.view.SurfaceHolder; Loading @@ -34,7 +32,6 @@ import dalvik.system.CloseGuard; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.UUID; Loading Loading @@ -241,47 +238,6 @@ public abstract class MediaPlayer2 implements AutoCloseable return new MediaPlayer2Impl(context); } private static final String[] decodeMediaPlayer2Uri(String location) { Uri uri = Uri.parse(location); if (!"mediaplayer2".equals(uri.getScheme())) { return new String[] {location}; } List<String> uris = uri.getQueryParameters("uri"); if (uris.isEmpty()) { return new String[] {location}; } List<String> keys = uri.getQueryParameters("key"); List<String> values = uri.getQueryParameters("value"); if (keys.size() != values.size()) { return new String[] {uris.get(0)}; } List<String> ls = new ArrayList(); ls.add(uris.get(0)); for (int i = 0; i < keys.size() ; i++) { ls.add(keys.get(i)); ls.add(values.get(i)); } return ls.toArray(new String[ls.size()]); } private static final String encodeMediaPlayer2Uri(String uri, String[] keys, String[] values) { Uri.Builder builder = new Uri.Builder(); builder.scheme("mediaplayer2").path("/").appendQueryParameter("uri", uri); if (keys == null || values == null || keys.length != values.length) { return builder.build().toString(); } for (int i = 0; i < keys.length ; i++) { builder .appendQueryParameter("key", keys[i]) .appendQueryParameter("value", values[i]); } return builder.build().toString(); } /** * @hide */ Loading @@ -290,12 +246,6 @@ public abstract class MediaPlayer2 implements AutoCloseable mGuard.open("close"); } /** * Returns a {@link MediaPlayerBase} implementation which runs based on * this MediaPlayer2 instance. */ public abstract MediaPlayerBase getMediaPlayerBase(); /** * Releases the resources held by this {@code MediaPlayer2} object. * Loading Loading @@ -342,8 +292,7 @@ public abstract class MediaPlayer2 implements AutoCloseable * Starts or resumes playback. If playback had previously been paused, * playback will continue from where it was paused. If playback had * reached end of stream and been paused, or never started before, * playback will start at the beginning. If the source had not been * prepared, the player will prepare the source and play. * playback will start at the beginning. * * @return a token which can be used to cancel the operation later with {@link #cancel}. */ Loading Loading @@ -404,9 +353,8 @@ public abstract class MediaPlayer2 implements AutoCloseable /** * Gets the current buffered media source position received through progressive downloading. * The received buffering percentage indicates how much of the content has been buffered * or played. For example a buffering update of 80 percent when half the content * has already been played indicates that the next 30 percent of the * For example a buffering update of 8000 milliseconds when 5000 milliseconds of the content * has already been played indicates that the next 3000 milliseconds of the * content to play has been buffered. * * @return the current buffered media source position in milliseconds Loading @@ -416,7 +364,6 @@ public abstract class MediaPlayer2 implements AutoCloseable /** * MediaPlayer2 has not been prepared or just has been reset. * In this state, MediaPlayer2 doesn't fetch data. * @hide */ public static final int PLAYER_STATE_IDLE = 1001; Loading @@ -424,26 +371,23 @@ public abstract class MediaPlayer2 implements AutoCloseable * MediaPlayer2 has been just prepared. * In this state, MediaPlayer2 just fetches data from media source, * but doesn't actively render data. * @hide */ public static final int PLAYER_STATE_PREPARED = 1002; /** * MediaPlayer2 is paused. * In this state, MediaPlayer2 doesn't actively render data. * @hide * In this state, MediaPlayer2 has allocated resources to construct playback * pipeline, but it doesn't actively render data. */ public static final int PLAYER_STATE_PAUSED = 1003; /** * MediaPlayer2 is actively playing back data. * @hide */ public static final int PLAYER_STATE_PLAYING = 1004; /** * MediaPlayer2 has hit some fatal error and cannot continue playback. * @hide */ public static final int PLAYER_STATE_ERROR = 1005; Loading @@ -469,7 +413,7 @@ public abstract class MediaPlayer2 implements AutoCloseable /** * Sets the audio attributes for this MediaPlayer2. * See {@link AudioAttributes} for how to build and configure an instance of this class. * You must call this method before {@link #prepare()} in order * You must call this method before {@link #play()} and {@link #pause()} in order * for the audio attributes to become effective thereafter. * @param attributes a non-null set of audio attributes * @return a token which can be used to cancel the operation later with {@link #cancel}. Loading Loading @@ -547,7 +491,7 @@ public abstract class MediaPlayer2 implements AutoCloseable public abstract Object setPlayerVolume(float volume); /** * Returns the current volume of this player to this player. * Returns the current volume of this player. * Note that it does not take into account the associated stream volume. * @return the player volume. */ Loading @@ -560,25 +504,10 @@ public abstract class MediaPlayer2 implements AutoCloseable return 1.0f; } /** * Create a request parcel which can be routed to the native media * player using {@link #invoke(Parcel, Parcel)}. The Parcel * returned has the proper InterfaceToken set. The caller should * not overwrite that token, i.e it can only append data to the * Parcel. * * @return A parcel suitable to hold a request for the native * player. * {@hide} */ public Parcel newRequest() { return null; } /** * Insert a task in the command queue to help the client to identify whether a batch * of commands has been finished. When this command is processed, a notification * {@code EventCallback.onCommandLabelReached} will be fired with the * {@link EventCallback#onCommandLabelReached onCommandLabelReached} will be fired with the * given {@code label}. * * @see EventCallback#onCommandLabelReached Loading @@ -601,10 +530,7 @@ public abstract class MediaPlayer2 implements AutoCloseable * played. * * @param sh the SurfaceHolder to use for video display * @throws IllegalStateException if the internal player engine has not been * initialized or has been released. * @return a token which can be used to cancel the operation later with {@link #cancel}. * @hide */ public abstract Object setDisplay(SurfaceHolder sh); Loading @@ -624,56 +550,44 @@ public abstract class MediaPlayer2 implements AutoCloseable * * @param surface The {@link Surface} to be used for the video portion of * the media. * @throws IllegalStateException if the internal player engine has not been * initialized or has been released. * @return a token which can be used to cancel the operation later with {@link #cancel}. */ // This is an asynchronous call. public abstract Object setSurface(Surface surface); /* Do not change these video scaling mode values below without updating * their counterparts in system/window.h! Please do not forget to update * {@link #isVideoScalingModeSupported} when new video scaling modes * are added. */ /** * Specifies a video scaling mode. The content is stretched to the * surface rendering area. When the surface has the same aspect ratio * as the content, the aspect ratio of the content is maintained; * otherwise, the aspect ratio of the content is not maintained when video * is being rendered. * There is no content cropping with this video scaling mode. */ public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT = 1; /** * Specifies a video scaling mode. The content is scaled, maintaining * its aspect ratio. The whole surface area is always used. When the * aspect ratio of the content is the same as the surface, no content * is cropped; otherwise, content is cropped to fit the surface. * @hide * Set the low-level power management behavior for this MediaPlayer2. This * can be used when the MediaPlayer2 is not playing through a SurfaceHolder * set with {@link #setDisplay(SurfaceHolder)} and thus can use the * high-level {@link #setScreenOnWhilePlaying(boolean)} feature. * * <p>This function has the MediaPlayer2 access the low-level power manager * service to control the device's power usage while playing is occurring. * The parameter is a combination of {@link android.os.PowerManager} wake flags. * Use of this method requires {@link android.Manifest.permission#WAKE_LOCK} * permission. * By default, no attempt is made to keep the device awake during playback. * * @param context the Context to use * @param mode the power/wake mode to set * @return a token which can be used to cancel the operation later with {@link #cancel}. * @see android.os.PowerManager */ public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING = 2; // This is an asynchronous call. public abstract Object setWakeMode(Context context, int mode); /** * Sets video scaling mode. To make the target video scaling mode * effective during playback, this method must be called after * data source is set. If not called, the default video * scaling mode is {@link #VIDEO_SCALING_MODE_SCALE_TO_FIT}. * * <p> The supported video scaling modes are: * <ul> * <li> {@link #VIDEO_SCALING_MODE_SCALE_TO_FIT} * </ul> * Control whether we should use the attached SurfaceHolder to keep the * screen on while video playback is occurring. This is the preferred * method over {@link #setWakeMode} where possible, since it doesn't * require that the application have permission for low-level wake lock * access. * * @param mode target video scaling mode. Must be one of the supported * video scaling modes; otherwise, IllegalArgumentException will be thrown. * @param screenOn Supply true to keep the screen on, false to allow it to turn off. * @return a token which can be used to cancel the operation later with {@link #cancel}. * * @see MediaPlayer2#VIDEO_SCALING_MODE_SCALE_TO_FIT * @hide */ public abstract Object setVideoScalingMode(int mode); // This is an asynchronous call. public abstract Object setScreenOnWhilePlaying(boolean screenOn); /** * Cancels a pending command. Loading Loading @@ -702,7 +616,7 @@ public abstract class MediaPlayer2 implements AutoCloseable * @return true if succesful, false if the specified {@link AudioDeviceInfo} is non-null and * does not correspond to a valid audio device. */ // This is an asynchronous call. // This is a synchronous call. @Override public abstract boolean setPreferredDevice(AudioDeviceInfo deviceInfo); Loading Loading @@ -746,36 +660,6 @@ public abstract class MediaPlayer2 implements AutoCloseable public abstract void removeOnRoutingChangedListener( AudioRouting.OnRoutingChangedListener listener); /** * Set the low-level power management behavior for this MediaPlayer2. * * <p>This function has the MediaPlayer2 access the low-level power manager * service to control the device's power usage while playing is occurring. * The parameter is a combination of {@link android.os.PowerManager} wake flags. * Use of this method requires {@link android.Manifest.permission#WAKE_LOCK} * permission. * By default, no attempt is made to keep the device awake during playback. * * @param context the Context to use * @param mode the power/wake mode to set * @see android.os.PowerManager * @hide */ public abstract void setWakeMode(Context context, int mode); /** * Control whether we should use the attached SurfaceHolder to keep the * screen on while video playback is occurring. This is the preferred * method over {@link #setWakeMode} where possible, since it doesn't * require that the application have permission for low-level wake lock * access. * * @param screenOn Supply true to keep the screen on, false to allow it * to turn off. * @hide */ public abstract void setScreenOnWhilePlaying(boolean screenOn); /** * Returns the width of the video. * Loading Loading @@ -1719,17 +1603,20 @@ public abstract class MediaPlayer2 implements AutoCloseable */ public static final int CALL_COMPLETED_SET_BUFFERING_PARAMS = 31; /** The player just completed a call {@link #setVideoScalingMode}. /** The player just completed a call {@link #setDisplay}. * @see EventCallback#onCallCompleted */ public static final int CALL_COMPLETED_SET_DISPLAY = 33; /** The player just completed a call {@link #setWakeMode}. * @see EventCallback#onCallCompleted * @hide */ public static final int CALL_COMPLETED_SET_VIDEO_SCALING_MODE = 32; public static final int CALL_COMPLETED_SET_WAKE_MODE = 34; /** The player just completed a call {@link #setDisplay}. /** The player just completed a call {@link #setScreenOnWhilePlaying}. * @see EventCallback#onCallCompleted * @hide */ public static final int CALL_COMPLETED_SET_DISPLAY = 33; public static final int CALL_COMPLETED_SET_SCREEN_ON_WHILE_PLAYING = 35; /** * The start of the methods which have separate call complete callback. Loading Loading @@ -1776,8 +1663,9 @@ public abstract class MediaPlayer2 implements AutoCloseable CALL_COMPLETED_SKIP_TO_NEXT, CALL_COMPLETED_CLEAR_NEXT_DATA_SOURCES, CALL_COMPLETED_SET_BUFFERING_PARAMS, CALL_COMPLETED_SET_VIDEO_SCALING_MODE, CALL_COMPLETED_SET_DISPLAY, CALL_COMPLETED_SET_WAKE_MODE, CALL_COMPLETED_SET_SCREEN_ON_WHILE_PLAYING, CALL_COMPLETED_NOTIFY_WHEN_COMMAND_LABEL_REACHED, CALL_COMPLETED_PREPARE_DRM, }) Loading
media/java/android/media/MediaPlayer2Impl.java +86 −364 File changed.Preview size limit exceeded, changes collapsed. Show changes
media/jni/android_media_MediaPlayer2.cpp +3 −18 Original line number Diff line number Diff line Loading @@ -893,20 +893,6 @@ android_media_MediaPlayer2_reset(JNIEnv *env, jobject thiz) process_media_player_call( env, thiz, mp->reset(), NULL, NULL ); } static jint android_media_MediaPlayer2_getAudioStreamType(JNIEnv *env, jobject thiz) { sp<MediaPlayer2> mp = getMediaPlayer(env, thiz); if (mp == NULL ) { jniThrowException(env, "java/lang/IllegalStateException", NULL); return 0; } audio_stream_type_t streamtype; process_media_player_call( env, thiz, mp->getAudioStreamType(&streamtype), NULL, NULL ); ALOGV("getAudioStreamType: %d (streamtype)", streamtype); return (jint) streamtype; } static jboolean android_media_MediaPlayer2_setParameter(JNIEnv *env, jobject thiz, jint key, jobject) { Loading Loading @@ -1467,7 +1453,7 @@ static const JNINativeMethod gMethods[] = { (void *)android_media_MediaPlayer2_handleDataSourceCallback }, {"nativePlayNextDataSource", "(J)V", (void *)android_media_MediaPlayer2_playNextDataSource}, {"_setVideoSurface", "(Landroid/view/Surface;)V", (void *)android_media_MediaPlayer2_setVideoSurface}, {"native_setVideoSurface", "(Landroid/view/Surface;)V", (void *)android_media_MediaPlayer2_setVideoSurface}, {"getBufferingParams", "()Landroid/media/BufferingParams;", (void *)android_media_MediaPlayer2_getBufferingParams}, {"_setBufferingParams", "(Landroid/media/BufferingParams;)V", (void *)android_media_MediaPlayer2_setBufferingParams}, {"_prepare", "()V", (void *)android_media_MediaPlayer2_prepare}, Loading @@ -1487,13 +1473,12 @@ static const JNINativeMethod gMethods[] = { {"getDuration", "()J", (void *)android_media_MediaPlayer2_getDuration}, {"_release", "()V", (void *)android_media_MediaPlayer2_release}, {"_reset", "()V", (void *)android_media_MediaPlayer2_reset}, {"_getAudioStreamType", "()I", (void *)android_media_MediaPlayer2_getAudioStreamType}, {"setParameter", "(ILjava/lang/Object;)Z", (void *)android_media_MediaPlayer2_setParameter}, {"getParameter", "(I)Ljava/lang/Object;", (void *)android_media_MediaPlayer2_getParameter}, {"setLooping", "(Z)V", (void *)android_media_MediaPlayer2_setLooping}, {"isLooping", "()Z", (void *)android_media_MediaPlayer2_isLooping}, {"_setVolume", "(F)V", (void *)android_media_MediaPlayer2_setVolume}, {"_invoke", "([B)[B", (void *)android_media_MediaPlayer2_invoke}, {"native_setVolume", "(F)V", (void *)android_media_MediaPlayer2_setVolume}, {"native_invoke", "([B)[B", (void *)android_media_MediaPlayer2_invoke}, {"native_init", "()V", (void *)android_media_MediaPlayer2_native_init}, {"native_setup", "(Ljava/lang/Object;)V", (void *)android_media_MediaPlayer2_native_setup}, {"native_finalize", "()V", (void *)android_media_MediaPlayer2_native_finalize}, Loading