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

Commit bbde56f5 authored by Insun Kang's avatar Insun Kang
Browse files

VideoView2: Adds more attributes and changes showSubtitle Api

- Adds more attributes
  - showSubtitle (boolean)
  - viewType (enum)
      - surfaceView
      - textureView
- showSubtitle --> showSubtitle(boolean)
- hideSubtitle --> removed

Test: build

Change-Id: I92ac9a9d167641d9a7107c82b334a8fa74bb5be9
parent 1e0a07b6
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -41,5 +41,4 @@
    <attr name="mediaRouteControlPanelThemeOverlay" format="reference" />

    <attr name="mediaRouteTheme" format="reference" />
    <attr name="enableControlView" format="boolean" />
</resources>
+43 −26
Original line number Diff line number Diff line
@@ -172,11 +172,29 @@ public class VideoView2Impl implements VideoView2Provider, VideoViewInterface.Su

        // TODO: Need a common namespace for attributes those are defined in updatable library.
        boolean enableControlView = (attrs == null) || attrs.getAttributeBooleanValue(
                "http://schemas.android.com/apk/com.android.media.update",
                "http://schemas.android.com/apk/res/android",
                "enableControlView", true);
        if (enableControlView) {
            mMediaControlView = new MediaControlView2(mInstance.getContext());
        }
        boolean showSubtitle = (attrs == null) || attrs.getAttributeBooleanValue(
                "http://schemas.android.com/apk/res/android",
                "showSubtitle", true);
        if (showSubtitle) {
            Log.d(TAG, "showSubtitle attribute is true.");
            // TODO: implement
        }
        int viewType = (attrs == null) ? VideoView2.VIEW_TYPE_SURFACEVIEW
                : attrs.getAttributeIntValue(
                "http://schemas.android.com/apk/res/android",
                "viewType", 0);
        if (viewType == 0) {
            Log.d(TAG, "viewType attribute is surfaceView.");
            // TODO: implement
        } else if (viewType == 1) {
            Log.d(TAG, "viewType attribute is textureView.");
            // TODO: implement
        }
    }

    @Override
@@ -202,7 +220,8 @@ public class VideoView2Impl implements VideoView2Provider, VideoViewInterface.Su
    }

    @Override
    public void showSubtitle_impl() {
    public void showSubtitle_impl(boolean show) {
        if (show) {
            // Retrieve all tracks that belong to the current video.
            MediaPlayer.TrackInfo[] trackInfos = mMediaPlayer.getTrackInfo();

@@ -219,15 +238,13 @@ public class VideoView2Impl implements VideoView2Provider, VideoViewInterface.Su
                mSelectedTrackIndex = subtitleTrackIndices.get(0);
                mMediaPlayer.selectTrack(mSelectedTrackIndex);
            }
    }

    @Override
    public void hideSubtitle_impl() {
        } else {
            if (mCCEnabled) {
                mMediaPlayer.deselectTrack(mSelectedTrackIndex);
                mCCEnabled = false;
            }
        }
    }

    // TODO: remove setSpeed_impl once MediaController2 is ready.
    @Override
@@ -901,10 +918,10 @@ public class VideoView2Impl implements VideoView2Provider, VideoViewInterface.Su
            } else {
                switch (command) {
                    case MediaControlView2.COMMAND_SHOW_SUBTITLE:
                        mInstance.showSubtitle();
                        mInstance.showSubtitle(true);
                        break;
                    case MediaControlView2.COMMAND_HIDE_SUBTITLE:
                        mInstance.hideSubtitle();
                        mInstance.showSubtitle(false);
                        break;
                    case MediaControlView2.COMMAND_SET_FULLSCREEN:
                        if (mOnFullScreenRequestListener != null) {