Loading packages/MediaComponents/res/layout/media_controller.xml +7 −1 Original line number Diff line number Diff line Loading @@ -136,7 +136,13 @@ android:layout_height="wrap_content" android:layout_centerVertical="true" android:visibility="gone" android:orientation="horizontal" > android:orientation="horizontal" android:gravity="center"> <LinearLayout android:id="@+id/custom_buttons" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ImageButton android:id="@+id/mute" Loading packages/MediaComponents/src/com/android/widget/MediaControlView2Impl.java +29 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.accessibility.AccessibilityManager; import android.widget.Button; import android.widget.ImageButton; import android.widget.MediaControlView2; import android.widget.ProgressBar; Loading @@ -40,6 +41,7 @@ import com.android.media.update.ApiHelper; import com.android.media.update.R; import java.util.Formatter; import java.util.List; import java.util.Locale; public class MediaControlView2Impl implements MediaControlView2Provider { Loading Loading @@ -97,6 +99,7 @@ public class MediaControlView2Impl implements MediaControlView2Provider { private ImageButton mOverflowButtonRight; private ViewGroup mExtraControls; private ViewGroup mCustomButtons; private ImageButton mOverflowButtonLeft; private ImageButton mMuteButton; private ImageButton mAspectRationButton; Loading Loading @@ -501,6 +504,7 @@ public class MediaControlView2Impl implements MediaControlView2Provider { // TODO: should these buttons be shown as default? mExtraControls = v.findViewById(R.id.extra_controls); mCustomButtons = v.findViewById(R.id.custom_buttons); mOverflowButtonLeft = v.findViewById(R.id.overflow_left); if (mOverflowButtonLeft != null) { mOverflowButtonLeft.setOnClickListener(mOverflowLeftListener); Loading Loading @@ -875,6 +879,31 @@ public class MediaControlView2Impl implements MediaControlView2Provider { } mPlaybackActions = newActions; } // Add buttons if custom actions are present. List<PlaybackState.CustomAction> customActions = mPlaybackState.getCustomActions(); mCustomButtons.removeAllViews(); if (customActions.size() > 0) { for (PlaybackState.CustomAction action : customActions) { ImageButton button = new ImageButton(mInstance.getContext(), null /* AttributeSet */, 0 /* Style */); // TODO: Apply R.style.BottomBarButton to this button using library context. // Refer Constructor with argument (int defStyleRes) of View.java button.setImageResource(action.getIcon()); button.setTooltipText(action.getName()); final String actionString = action.getAction().toString(); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO: Currently, we are just sending extras that came from session. // Is it the right behavior? mControls.sendCustomAction(actionString, action.getExtras()); mInstance.show(DEFAULT_TIMEOUT_MS); } }); mCustomButtons.addView(button); } } } @Override Loading packages/MediaComponents/src/com/android/widget/VideoView2Impl.java +24 −2 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ public class VideoView2Impl implements VideoView2Provider, VideoViewInterface.Su private AudioAttributes mAudioAttributes; private int mAudioFocusType = AudioManager.AUDIOFOCUS_GAIN; // legacy focus gain private VideoView2.OnCustomActionListener mOnCustomActionListener; private VideoView2.OnPreparedListener mOnPreparedListener; private VideoView2.OnCompletionListener mOnCompletionListener; private VideoView2.OnErrorListener mOnErrorListener; Loading @@ -98,6 +99,7 @@ public class VideoView2Impl implements VideoView2Provider, VideoViewInterface.Su private String mTitle; private PlaybackState.Builder mStateBuilder; private List<PlaybackState.CustomAction> mCustomActionList; private int mTargetState = STATE_IDLE; private int mCurrentState = STATE_IDLE; private int mCurrentBufferPercentage; Loading Loading @@ -305,6 +307,17 @@ public class VideoView2Impl implements VideoView2Provider, VideoViewInterface.Su return mCurrentView.getViewType(); } @Override public void setCustomActions_impl(List<PlaybackState.CustomAction> actionList, VideoView2.OnCustomActionListener listener) { mCustomActionList = actionList; mOnCustomActionListener = listener; // Create a new playback builder in order to clear existing the custom actions. mStateBuilder = null; updatePlaybackState(); } @Override public void setOnPreparedListener_impl(VideoView2.OnPreparedListener l) { mOnPreparedListener = l; Loading Loading @@ -642,8 +655,12 @@ public class VideoView2Impl implements VideoView2Provider, VideoViewInterface.Su } mStateBuilder = new PlaybackState.Builder(); mStateBuilder.setActions(playbackActions); mStateBuilder.addCustomAction(MediaControlView2Impl.COMMAND_SHOW_SUBTITLE, null, -1); mStateBuilder.addCustomAction(MediaControlView2Impl.COMMAND_HIDE_SUBTITLE, null, -1); if (mCustomActionList != null) { for (PlaybackState.CustomAction action : mCustomActionList) { mStateBuilder.addCustomAction(action); } } } mStateBuilder.setState(getCorrespondingPlaybackState(), mMediaPlayer.getCurrentPosition(), mSpeed); Loading Loading @@ -912,6 +929,11 @@ public class VideoView2Impl implements VideoView2Provider, VideoViewInterface.Su } } @Override public void onCustomAction(String action, Bundle extras) { mOnCustomActionListener.onCustomAction(action, extras); } @Override public void onPlay() { if (isInPlaybackState() && mCurrentView.hasAvailableSurface()) { Loading Loading
packages/MediaComponents/res/layout/media_controller.xml +7 −1 Original line number Diff line number Diff line Loading @@ -136,7 +136,13 @@ android:layout_height="wrap_content" android:layout_centerVertical="true" android:visibility="gone" android:orientation="horizontal" > android:orientation="horizontal" android:gravity="center"> <LinearLayout android:id="@+id/custom_buttons" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ImageButton android:id="@+id/mute" Loading
packages/MediaComponents/src/com/android/widget/MediaControlView2Impl.java +29 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.accessibility.AccessibilityManager; import android.widget.Button; import android.widget.ImageButton; import android.widget.MediaControlView2; import android.widget.ProgressBar; Loading @@ -40,6 +41,7 @@ import com.android.media.update.ApiHelper; import com.android.media.update.R; import java.util.Formatter; import java.util.List; import java.util.Locale; public class MediaControlView2Impl implements MediaControlView2Provider { Loading Loading @@ -97,6 +99,7 @@ public class MediaControlView2Impl implements MediaControlView2Provider { private ImageButton mOverflowButtonRight; private ViewGroup mExtraControls; private ViewGroup mCustomButtons; private ImageButton mOverflowButtonLeft; private ImageButton mMuteButton; private ImageButton mAspectRationButton; Loading Loading @@ -501,6 +504,7 @@ public class MediaControlView2Impl implements MediaControlView2Provider { // TODO: should these buttons be shown as default? mExtraControls = v.findViewById(R.id.extra_controls); mCustomButtons = v.findViewById(R.id.custom_buttons); mOverflowButtonLeft = v.findViewById(R.id.overflow_left); if (mOverflowButtonLeft != null) { mOverflowButtonLeft.setOnClickListener(mOverflowLeftListener); Loading Loading @@ -875,6 +879,31 @@ public class MediaControlView2Impl implements MediaControlView2Provider { } mPlaybackActions = newActions; } // Add buttons if custom actions are present. List<PlaybackState.CustomAction> customActions = mPlaybackState.getCustomActions(); mCustomButtons.removeAllViews(); if (customActions.size() > 0) { for (PlaybackState.CustomAction action : customActions) { ImageButton button = new ImageButton(mInstance.getContext(), null /* AttributeSet */, 0 /* Style */); // TODO: Apply R.style.BottomBarButton to this button using library context. // Refer Constructor with argument (int defStyleRes) of View.java button.setImageResource(action.getIcon()); button.setTooltipText(action.getName()); final String actionString = action.getAction().toString(); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO: Currently, we are just sending extras that came from session. // Is it the right behavior? mControls.sendCustomAction(actionString, action.getExtras()); mInstance.show(DEFAULT_TIMEOUT_MS); } }); mCustomButtons.addView(button); } } } @Override Loading
packages/MediaComponents/src/com/android/widget/VideoView2Impl.java +24 −2 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ public class VideoView2Impl implements VideoView2Provider, VideoViewInterface.Su private AudioAttributes mAudioAttributes; private int mAudioFocusType = AudioManager.AUDIOFOCUS_GAIN; // legacy focus gain private VideoView2.OnCustomActionListener mOnCustomActionListener; private VideoView2.OnPreparedListener mOnPreparedListener; private VideoView2.OnCompletionListener mOnCompletionListener; private VideoView2.OnErrorListener mOnErrorListener; Loading @@ -98,6 +99,7 @@ public class VideoView2Impl implements VideoView2Provider, VideoViewInterface.Su private String mTitle; private PlaybackState.Builder mStateBuilder; private List<PlaybackState.CustomAction> mCustomActionList; private int mTargetState = STATE_IDLE; private int mCurrentState = STATE_IDLE; private int mCurrentBufferPercentage; Loading Loading @@ -305,6 +307,17 @@ public class VideoView2Impl implements VideoView2Provider, VideoViewInterface.Su return mCurrentView.getViewType(); } @Override public void setCustomActions_impl(List<PlaybackState.CustomAction> actionList, VideoView2.OnCustomActionListener listener) { mCustomActionList = actionList; mOnCustomActionListener = listener; // Create a new playback builder in order to clear existing the custom actions. mStateBuilder = null; updatePlaybackState(); } @Override public void setOnPreparedListener_impl(VideoView2.OnPreparedListener l) { mOnPreparedListener = l; Loading Loading @@ -642,8 +655,12 @@ public class VideoView2Impl implements VideoView2Provider, VideoViewInterface.Su } mStateBuilder = new PlaybackState.Builder(); mStateBuilder.setActions(playbackActions); mStateBuilder.addCustomAction(MediaControlView2Impl.COMMAND_SHOW_SUBTITLE, null, -1); mStateBuilder.addCustomAction(MediaControlView2Impl.COMMAND_HIDE_SUBTITLE, null, -1); if (mCustomActionList != null) { for (PlaybackState.CustomAction action : mCustomActionList) { mStateBuilder.addCustomAction(action); } } } mStateBuilder.setState(getCorrespondingPlaybackState(), mMediaPlayer.getCurrentPosition(), mSpeed); Loading Loading @@ -912,6 +929,11 @@ public class VideoView2Impl implements VideoView2Provider, VideoViewInterface.Su } } @Override public void onCustomAction(String action, Bundle extras) { mOnCustomActionListener.onCustomAction(action, extras); } @Override public void onPlay() { if (isInPlaybackState() && mCurrentView.hasAvailableSurface()) { Loading