Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ae4ff743 authored by Wei Jia's avatar Wei Jia
Browse files

MediaPlayer2: add Context to create MediaPlayer2

Test: cts
Bug: 112549021
Change-Id: I7eb4f5483f07a71d962bd447c20f765dd8f5bdf6
parent c474bfd0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -242,8 +242,8 @@ public abstract class MediaPlayer2 implements SubtitleController.Listener
     *
     * @return A MediaPlayer2 object created
     */
    public static final MediaPlayer2 create() {
        return new MediaPlayer2Impl();
    public static final MediaPlayer2 create(Context context) {
        return new MediaPlayer2Impl(context);
    }

    private static final String[] decodeMediaPlayer2Uri(String location) {
+4 −1
Original line number Diff line number Diff line
@@ -93,6 +93,8 @@ public final class MediaPlayer2Impl extends MediaPlayer2 {

    private final static String TAG = "MediaPlayer2Impl";

    private Context mContext;

    private long mNativeContext; // accessed by native methods
    private long mNativeSurfaceTexture;  // accessed by native methods
    private int mListenerContext; // accessed by native methods
@@ -149,7 +151,8 @@ public final class MediaPlayer2Impl extends MediaPlayer2 {
     * to free the resources. If not released, too many MediaPlayer2Impl instances may
     * result in an exception.</p>
     */
    public MediaPlayer2Impl() {
    public MediaPlayer2Impl(Context context) {
        mContext = context;
        mHandlerThread = new HandlerThread("MediaPlayer2TaskThread");
        mHandlerThread.start();
        Looper looper = mHandlerThread.getLooper();