MediaControlView2: Add support for Minimal Mode
This CL adds UX for Minimal mode.
- Minimal mode is triggered when the minimum width required for
Embedded mode is smaller than the current View width.
- Create an MinimalExtraView to place FullScreen button for
Minimal mode.
This CL also adds gradient background color for TitleBar and
implements onCallCompleted() callback to update MediaControlView2
after successfully seeking.
Bug: 74506210
Test: VideoViewTest.apk
Change-Id: I6cd35af473d0f796cd35ae8759171cc1722fc679
diff --git a/packages/MediaComponents/res/drawable/custom_progress_thumb.xml b/packages/MediaComponents/res/drawable/custom_progress_thumb.xml
index 2e247f2..1a35970 100644
--- a/packages/MediaComponents/res/drawable/custom_progress_thumb.xml
+++ b/packages/MediaComponents/res/drawable/custom_progress_thumb.xml
@@ -17,6 +17,6 @@
android:shape="oval" >
<solid android:color="#ffffff" />
<size
- android:height="12dp"
- android:width="12dp" />
+ android:height="@dimen/mcv2_custom_progress_thumb_size"
+ android:width="@dimen/mcv2_custom_progress_thumb_size" />
</shape>
\ No newline at end of file
diff --git a/packages/MediaComponents/res/layout/media_controller.xml b/packages/MediaComponents/res/layout/media_controller.xml
index ffaf03f..4658f04 100644
--- a/packages/MediaComponents/res/layout/media_controller.xml
+++ b/packages/MediaComponents/res/layout/media_controller.xml
@@ -17,12 +17,12 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="#55000000"
android:orientation="vertical"
android:layoutDirection="ltr">
<RelativeLayout
android:id="@+id/title_bar"
+ android:background="@layout/title_bar_gradient"
style="@style/TitleBar">
<LinearLayout
@@ -114,22 +114,51 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
- android:gravity="center">
+ android:gravity="center"
+ android:orientation="vertical">
</LinearLayout>
- <SeekBar
- android:id="@+id/mediacontroller_progress"
- android:contentDescription="@string/mcv2_seek_bar_desc"
+ <LinearLayout
+ android:id="@+id/minimal_extra_view"
android:layout_width="match_parent"
- android:layout_height="12dp"
- android:maxHeight="2dp"
- android:minHeight="2dp"
- android:padding="0dp"/>
+ android:layout_height="wrap_content"
+ android:gravity="right">
+
+ <ImageButton
+ android:id="@+id/fullscreen"
+ android:gravity="right"
+ style="@style/BottomBarButton.FullScreen" />
+ </LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
+ android:layout_height="@dimen/mcv2_custom_progress_thumb_size">
+
+ <SeekBar
+ android:id="@+id/progress"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/mcv2_custom_progress_thumb_size"
+ android:contentDescription="@string/mcv2_seek_bar_desc"
+ android:padding="0dp"
+ android:maxHeight="@dimen/mcv2_custom_progress_max_size"
+ android:minHeight="@dimen/mcv2_custom_progress_max_size"
+ android:elevation="10dp"/>
+
+ <View
+ android:id="@+id/progress_buffer"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/mcv2_buffer_view_height"
+ android:layout_alignParentBottom="true"
+ android:background="@color/bottom_bar_background"
+ android:elevation="0dp"/>
+ </RelativeLayout>
+
+ <RelativeLayout
+ android:id="@+id/bottom_bar"
+ android:layout_width="match_parent"
android:layout_height="44dp"
- android:orientation="horizontal">
+ android:orientation="horizontal"
+ android:background="@color/bottom_bar_background">
<LinearLayout
android:id="@+id/bottom_bar_left"
diff --git a/packages/MediaComponents/res/layout/minimal_transport_controls.xml b/packages/MediaComponents/res/layout/minimal_transport_controls.xml
index 9ca3721..800c80b 100644
--- a/packages/MediaComponents/res/layout/minimal_transport_controls.xml
+++ b/packages/MediaComponents/res/layout/minimal_transport_controls.xml
@@ -18,8 +18,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
- android:orientation="horizontal"
- android:visibility="visible">
+ android:orientation="horizontal">
- <ImageButton android:id="@+id/pause" style="@style/MinimalTransportControlsButton.Pause" />
+ <ImageButton android:id="@+id/pause" style="@style/MinimalTransportControlsButton" />
</LinearLayout>
\ No newline at end of file
diff --git a/packages/MediaComponents/res/layout/title_bar_gradient.xml b/packages/MediaComponents/res/layout/title_bar_gradient.xml
new file mode 100644
index 0000000..ab1fc6e
--- /dev/null
+++ b/packages/MediaComponents/res/layout/title_bar_gradient.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <gradient
+ android:startColor="@color/title_bar_gradient_start"
+ android:endColor="@color/title_bar_gradient_end"
+ android:angle="-270" />
+</shape>
\ No newline at end of file
diff --git a/packages/MediaComponents/res/values/colors.xml b/packages/MediaComponents/res/values/colors.xml
index 6a65ef5..e7bc299 100644
--- a/packages/MediaComponents/res/values/colors.xml
+++ b/packages/MediaComponents/res/values/colors.xml
@@ -19,4 +19,7 @@
<color name="white">#ffffff</color>
<color name="white_opacity_70">#B3ffffff</color>
<color name="black_opacity_70">#B3000000</color>
+ <color name="title_bar_gradient_start">#50000000</color>
+ <color name="title_bar_gradient_end">#00000000</color>
+ <color name="bottom_bar_background">#40202020</color>
</resources>
\ No newline at end of file
diff --git a/packages/MediaComponents/res/values/dimens.xml b/packages/MediaComponents/res/values/dimens.xml
index 62bc196..2d7b022 100644
--- a/packages/MediaComponents/res/values/dimens.xml
+++ b/packages/MediaComponents/res/values/dimens.xml
@@ -65,5 +65,8 @@
<dimen name="mcv2_full_album_image_portrait_size">232dp</dimen>
<dimen name="mcv2_full_album_image_landscape_size">176dp</dimen>
+ <dimen name="mcv2_custom_progress_max_size">2dp</dimen>
+ <dimen name="mcv2_custom_progress_thumb_size">12dp</dimen>
+ <dimen name="mcv2_buffer_view_height">5dp</dimen>
<!-- TODO: adjust bottom bar view -->
</resources>
diff --git a/packages/MediaComponents/res/values/style.xml b/packages/MediaComponents/res/values/style.xml
index 76a21c4..5b9a8ee 100644
--- a/packages/MediaComponents/res/values/style.xml
+++ b/packages/MediaComponents/res/values/style.xml
@@ -84,21 +84,19 @@
<style name="MinimalTransportControlsButton">
<item name="android:background">@null</item>
+ <item name="android:layout_width">@dimen/mcv2_pause_icon_size</item>
+ <item name="android:layout_height">@dimen/mcv2_pause_icon_size</item>
+ <item name="android:layout_margin">@dimen/mcv2_icon_margin</item>
<item name="android:scaleType">fitXY</item>
- </style>
-
- <style name="MinimalTransportControlsButton.Pause">
<item name="android:src">@drawable/ic_pause_circle_filled</item>
- <item name="android:layout_width">@dimen/mcv2_minimal_icon_size</item>
- <item name="android:layout_height">@dimen/mcv2_minimal_icon_size</item>
<item name="android:contentDescription">@string/mcv2_pause_button_desc</item>
</style>
<style name="TitleBar">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">46dp</item>
- <item name="android:layout_marginLeft">5dp</item>
- <item name="android:layout_marginRight">5dp</item>
+ <item name="android:paddingStart">5dp</item>
+ <item name="android:paddingEnd">5dp</item>
</style>
<style name="TitleBarButton">
diff --git a/packages/MediaComponents/src/com/android/widget/MediaControlView2Impl.java b/packages/MediaComponents/src/com/android/widget/MediaControlView2Impl.java
index 7134004..3aff150 100644
--- a/packages/MediaComponents/src/com/android/widget/MediaControlView2Impl.java
+++ b/packages/MediaComponents/src/com/android/widget/MediaControlView2Impl.java
@@ -159,7 +159,7 @@
private boolean mNeedUXUpdate;
// Relating to Title Bar View
- private View mRoot;
+ private ViewGroup mRoot;
private View mTitleBar;
private TextView mTitleView;
private View mAdExternalLink;
@@ -176,8 +176,15 @@
private ImageButton mNextButton;
private ImageButton mPrevButton;
+ // Relating to Minimal Extra View
+ private LinearLayout mMinimalExtraView;
+
// Relating to Progress Bar View
private ProgressBar mProgress;
+ private View mProgressBuffer;
+
+ // Relating to Bottom Bar View
+ private ViewGroup mBottomBar;
// Relating to Bottom Bar Left View
private ViewGroup mBottomBarLeftView;
@@ -363,53 +370,36 @@
manager.getDefaultDisplay().getSize(screenSize);
int screenWidth = screenSize.x;
int screenHeight = screenSize.y;
- int screenMaxLength = Math.max(screenWidth, screenHeight);
+ int fullIconSize = mResources.getDimensionPixelSize(R.dimen.mcv2_full_icon_size);
+ int embeddedIconSize = mResources.getDimensionPixelSize(
+ R.dimen.mcv2_embedded_icon_size);
+ int marginSize = mResources.getDimensionPixelSize(R.dimen.mcv2_icon_margin);
// TODO: add support for Advertisement Mode.
if (mMediaType == MEDIA_TYPE_DEFAULT) {
- int iconSize = mResources.getDimensionPixelSize(R.dimen.mcv2_full_icon_size);
- int marginSize = mResources.getDimensionPixelSize(R.dimen.mcv2_icon_margin);
- // Currently, the maximum number of icons the BottomBar can have is 4 icons. When
- // calculating the minimum amount of space needed to place all these icons, however,
- // we also need to add the amount of margins on both the right and left sides of the
- // buttons.
- int bottomBarRightWidthMax = 4 * (iconSize + marginSize * 2);
- int fullWidth = mTransportControls.getWidth() + mTimeView.getWidth()
- + bottomBarRightWidthMax;
- if (fullWidth > screenMaxLength) {
- // TODO: screen may be smaller than the length needed for Full size.
- }
- if (currWidth == screenMaxLength) {
- if (mSizeType != SIZE_TYPE_FULL) {
- updateDefaultLayoutForSizeChange(SIZE_TYPE_FULL);
- }
- } else {
- if (mSizeType != SIZE_TYPE_EMBEDDED) {
- updateDefaultLayoutForSizeChange(SIZE_TYPE_EMBEDDED);
- }
- }
+ // Max number of icons inside BottomBarRightView for Music mode is 4.
+ int maxIconCount = 4;
+ updateLayout(maxIconCount, fullIconSize, embeddedIconSize, marginSize, currWidth,
+ currHeight, screenWidth, screenHeight);
} else if (mMediaType == MEDIA_TYPE_MUSIC) {
if (mNeedUXUpdate) {
// One-time operation for Music media type
mBasicControls.removeView(mMuteButton);
mExtraControls.addView(mMuteButton, 0);
mVideoQualityButton.setVisibility(View.GONE);
- mFfwdButton.setVisibility(View.GONE);
- mRewButton.setVisibility(View.GONE);
+ if (mFfwdButton != null) {
+ mFfwdButton.setVisibility(View.GONE);
+ }
+ if (mRewButton != null) {
+ mRewButton.setVisibility(View.GONE);
+ }
}
mNeedUXUpdate = false;
- if (currWidth == screenWidth && currHeight == screenHeight) {
- if (mSizeType != SIZE_TYPE_FULL) {
- updateDefaultLayoutForSizeChange(SIZE_TYPE_FULL);
- mTitleView.setVisibility(View.GONE);
- }
- } else {
- if (mSizeType != SIZE_TYPE_EMBEDDED) {
- updateDefaultLayoutForSizeChange(SIZE_TYPE_EMBEDDED);
- mTitleView.setVisibility(View.VISIBLE);
- }
- }
+ // Max number of icons inside BottomBarRightView for Music mode is 3.
+ int maxIconCount = 3;
+ updateLayout(maxIconCount, fullIconSize, embeddedIconSize, marginSize, currWidth,
+ currHeight, screenWidth, screenHeight);
}
mPrevWidth = currWidth;
mPrevHeight = currHeight;
@@ -529,13 +519,14 @@
* @return The controller view.
* @hide This doesn't work as advertised
*/
- protected View makeControllerView() {
- View root = ApiHelper.inflateLibLayout(mInstance.getContext(), R.layout.media_controller);
+ protected ViewGroup makeControllerView() {
+ ViewGroup root = (ViewGroup) ApiHelper.inflateLibLayout(mInstance.getContext(),
+ R.layout.media_controller);
initControllerView(root);
return root;
}
- private void initControllerView(View v) {
+ private void initControllerView(ViewGroup v) {
// Relating to Title Bar View
mTitleBar = v.findViewById(R.id.title_bar);
mTitleView = v.findViewById(R.id.title_text);
@@ -552,8 +543,18 @@
mTransportControls = inflateTransportControls(R.layout.embedded_transport_controls);
mCenterView.addView(mTransportControls);
+ // Relating to Minimal Extra View
+ mMinimalExtraView = (LinearLayout) v.findViewById(R.id.minimal_extra_view);
+ LinearLayout.LayoutParams params =
+ (LinearLayout.LayoutParams) mMinimalExtraView.getLayoutParams();
+ int iconSize = mResources.getDimensionPixelSize(R.dimen.mcv2_embedded_icon_size);
+ int marginSize = mResources.getDimensionPixelSize(R.dimen.mcv2_icon_margin);
+ params.setMargins(0, (iconSize + marginSize * 2) * (-1), 0, 0);
+ mMinimalExtraView.setLayoutParams(params);
+ mMinimalExtraView.setVisibility(View.GONE);
+
// Relating to Progress Bar View
- mProgress = v.findViewById(R.id.mediacontroller_progress);
+ mProgress = v.findViewById(R.id.progress);
if (mProgress != null) {
if (mProgress instanceof SeekBar) {
SeekBar seeker = (SeekBar) mProgress;
@@ -563,6 +564,10 @@
}
mProgress.setMax(MAX_PROGRESS);
}
+ mProgressBuffer = v.findViewById(R.id.progress_buffer);
+
+ // Relating to Bottom Bar View
+ mBottomBar = v.findViewById(R.id.bottom_bar);
// Relating to Bottom Bar Left View
mBottomBarLeftView = v.findViewById(R.id.bottom_bar_left);
@@ -819,11 +824,11 @@
return;
}
if (mDuration > 0) {
- int newPosition = (int) (((long) mDuration * progress) / MAX_PROGRESS);
- mControls.seekTo(newPosition);
+ int position = (int) (((long) mDuration * progress) / MAX_PROGRESS);
+ mControls.seekTo(position);
if (mCurrentTime != null) {
- mCurrentTime.setText(stringForTime(newPosition));
+ mCurrentTime.setText(stringForTime(position));
}
}
}
@@ -1161,42 +1166,135 @@
}
}
- private void updateDefaultLayoutForSizeChange(int sizeType) {
+ private void updateLayout(int maxIconCount, int fullIconSize, int embeddedIconSize,
+ int marginSize, int currWidth, int currHeight, int screenWidth, int screenHeight) {
+ int fullBottomBarRightWidthMax = fullIconSize * maxIconCount
+ + marginSize * (maxIconCount * 2);
+ int embeddedBottomBarRightWidthMax = embeddedIconSize * maxIconCount
+ + marginSize * (maxIconCount * 2);
+ int fullWidth = mTransportControls.getWidth() + mTimeView.getWidth()
+ + fullBottomBarRightWidthMax;
+ int embeddedWidth = mTimeView.getWidth() + embeddedBottomBarRightWidthMax;
+ int screenMaxLength = Math.max(screenWidth, screenHeight);
+
+ if (fullWidth > screenMaxLength) {
+ // TODO: screen may be smaller than the length needed for Full size.
+ }
+
+ boolean isFullSize = (mMediaType == MEDIA_TYPE_DEFAULT) ? (currWidth == screenMaxLength) :
+ (currWidth == screenWidth && currHeight == screenHeight);
+
+ if (isFullSize) {
+ if (mSizeType != SIZE_TYPE_FULL) {
+ updateLayoutForSizeChange(SIZE_TYPE_FULL);
+ if (mMediaType == MEDIA_TYPE_MUSIC) {
+ mTitleView.setVisibility(View.GONE);
+ }
+ }
+ } else if (embeddedWidth <= currWidth) {
+ if (mSizeType != SIZE_TYPE_EMBEDDED) {
+ updateLayoutForSizeChange(SIZE_TYPE_EMBEDDED);
+ if (mMediaType == MEDIA_TYPE_MUSIC) {
+ mTitleView.setVisibility(View.VISIBLE);
+ }
+ }
+ } else {
+ if (mSizeType != SIZE_TYPE_MINIMAL) {
+ updateLayoutForSizeChange(SIZE_TYPE_MINIMAL);
+ if (mMediaType == MEDIA_TYPE_MUSIC) {
+ mTitleView.setVisibility(View.GONE);
+ }
+ }
+ }
+ }
+
+ private void updateLayoutForSizeChange(int sizeType) {
mSizeType = sizeType;
- RelativeLayout.LayoutParams params =
+ RelativeLayout.LayoutParams timeViewParams =
(RelativeLayout.LayoutParams) mTimeView.getLayoutParams();
+ SeekBar seeker = (SeekBar) mProgress;
switch (mSizeType) {
case SIZE_TYPE_EMBEDDED:
+ // Relating to Title Bar
+ mTitleBar.setVisibility(View.VISIBLE);
+ mBackButton.setVisibility(View.GONE);
+
+ // Relating to Full Screen Button
+ mMinimalExtraView.setVisibility(View.GONE);
+ mFullScreenButton = mBottomBarRightView.findViewById(R.id.fullscreen);
+ mFullScreenButton.setOnClickListener(mFullScreenListener);
+
+ // Relating to Center View
+ mCenterView.removeAllViews();
mBottomBarLeftView.removeView(mTransportControls);
mBottomBarLeftView.setVisibility(View.GONE);
mTransportControls = inflateTransportControls(R.layout.embedded_transport_controls);
mCenterView.addView(mTransportControls);
- if (params.getRule(RelativeLayout.LEFT_OF) != 0) {
- params.removeRule(RelativeLayout.LEFT_OF);
- params.addRule(RelativeLayout.RIGHT_OF, R.id.bottom_bar_left);
- }
+ // Relating to Progress Bar
+ seeker.setThumb(mResources.getDrawable(R.drawable.custom_progress_thumb));
+ mProgressBuffer.setVisibility(View.VISIBLE);
- mBackButton.setVisibility(View.GONE);
+ // Relating to Bottom Bar
+ mBottomBar.setVisibility(View.VISIBLE);
+ if (timeViewParams.getRule(RelativeLayout.LEFT_OF) != 0) {
+ timeViewParams.removeRule(RelativeLayout.LEFT_OF);
+ timeViewParams.addRule(RelativeLayout.RIGHT_OF, R.id.bottom_bar_left);
+ }
break;
case SIZE_TYPE_FULL:
- mCenterView.removeView(mTransportControls);
+ // Relating to Title Bar
+ mTitleBar.setVisibility(View.VISIBLE);
+ mBackButton.setVisibility(View.VISIBLE);
+
+ // Relating to Full Screen Button
+ mMinimalExtraView.setVisibility(View.GONE);
+ mFullScreenButton = mBottomBarRightView.findViewById(R.id.fullscreen);
+ mFullScreenButton.setOnClickListener(mFullScreenListener);
+
+ // Relating to Center View
+ mCenterView.removeAllViews();
+ mBottomBarLeftView.removeView(mTransportControls);
mTransportControls = inflateTransportControls(R.layout.full_transport_controls);
mBottomBarLeftView.addView(mTransportControls, 0);
mBottomBarLeftView.setVisibility(View.VISIBLE);
- if (params.getRule(RelativeLayout.RIGHT_OF) != 0) {
- params.removeRule(RelativeLayout.RIGHT_OF);
- params.addRule(RelativeLayout.LEFT_OF, R.id.bottom_bar_right);
- }
+ // Relating to Progress Bar
+ seeker.setThumb(mResources.getDrawable(R.drawable.custom_progress_thumb));
+ mProgressBuffer.setVisibility(View.VISIBLE);
- mBackButton.setVisibility(View.VISIBLE);
+ // Relating to Bottom Bar
+ mBottomBar.setVisibility(View.VISIBLE);
+ if (timeViewParams.getRule(RelativeLayout.RIGHT_OF) != 0) {
+ timeViewParams.removeRule(RelativeLayout.RIGHT_OF);
+ timeViewParams.addRule(RelativeLayout.LEFT_OF, R.id.bottom_bar_right);
+ }
break;
case SIZE_TYPE_MINIMAL:
- // TODO: implement
+ // Relating to Title Bar
+ mTitleBar.setVisibility(View.GONE);
+ mBackButton.setVisibility(View.GONE);
+
+ // Relating to Full Screen Button
+ mMinimalExtraView.setVisibility(View.VISIBLE);
+ mFullScreenButton = mMinimalExtraView.findViewById(R.id.fullscreen);
+ mFullScreenButton.setOnClickListener(mFullScreenListener);
+
+ // Relating to Center View
+ mCenterView.removeAllViews();
+ mBottomBarLeftView.removeView(mTransportControls);
+ mTransportControls = inflateTransportControls(R.layout.minimal_transport_controls);
+ mCenterView.addView(mTransportControls);
+
+ // Relating to Progress Bar
+ seeker.setThumb(null);
+ mProgressBuffer.setVisibility(View.GONE);
+
+ // Relating to Bottom Bar
+ mBottomBar.setVisibility(View.GONE);
break;
}
- mTimeView.setLayoutParams(params);
+ mTimeView.setLayoutParams(timeViewParams);
if (isPlaying()) {
mPlayPauseButton.setImageDrawable(
@@ -1209,6 +1307,14 @@
mPlayPauseButton.setContentDescription(
mResources.getString(R.string.mcv2_play_button_desc));
}
+
+ if (mIsFullScreen) {
+ mFullScreenButton.setImageDrawable(
+ mResources.getDrawable(R.drawable.ic_fullscreen_exit, null));
+ } else {
+ mFullScreenButton.setImageDrawable(
+ mResources.getDrawable(R.drawable.ic_fullscreen, null));
+ }
}
private View inflateTransportControls(int layoutId) {
@@ -1221,10 +1327,16 @@
mFfwdButton = v.findViewById(R.id.ffwd);
if (mFfwdButton != null) {
mFfwdButton.setOnClickListener(mFfwdListener);
+ if (mMediaType == MEDIA_TYPE_MUSIC) {
+ mFfwdButton.setVisibility(View.GONE);
+ }
}
mRewButton = v.findViewById(R.id.rew);
if (mRewButton != null) {
mRewButton.setOnClickListener(mRewListener);
+ if (mMediaType == MEDIA_TYPE_MUSIC) {
+ mRewButton.setVisibility(View.GONE);
+ }
}
// TODO: Add support for Next and Previous buttons
mNextButton = v.findViewById(R.id.next);
@@ -1237,11 +1349,6 @@
mPrevButton.setOnClickListener(mPrevListener);
mPrevButton.setVisibility(View.GONE);
}
-
- if (mMediaType == MEDIA_TYPE_MUSIC) {
- mFfwdButton.setVisibility(View.GONE);
- mRewButton.setVisibility(View.GONE);
- }
return v;
}
@@ -1351,11 +1458,15 @@
}
if ((newActions & PlaybackState.ACTION_REWIND) != 0
&& mMediaType != MEDIA_TYPE_MUSIC) {
- mRewButton.setVisibility(View.VISIBLE);
+ if (mRewButton != null) {
+ mRewButton.setVisibility(View.VISIBLE);
+ }
}
if ((newActions & PlaybackState.ACTION_FAST_FORWARD) != 0
&& mMediaType != MEDIA_TYPE_MUSIC) {
- mFfwdButton.setVisibility(View.VISIBLE);
+ if (mFfwdButton != null) {
+ mFfwdButton.setVisibility(View.VISIBLE);
+ }
}
if ((newActions & PlaybackState.ACTION_SEEK_TO) != 0) {
mSeekAvailable = true;
diff --git a/packages/MediaComponents/src/com/android/widget/VideoView2Impl.java b/packages/MediaComponents/src/com/android/widget/VideoView2Impl.java
index 156ee5a..b2acc26 100644
--- a/packages/MediaComponents/src/com/android/widget/VideoView2Impl.java
+++ b/packages/MediaComponents/src/com/android/widget/VideoView2Impl.java
@@ -1190,6 +1190,14 @@
}
}
+ @Override
+ public void onCallCompleted(MediaPlayer2 mp, DataSourceDesc dsd, int what,
+ int status) {
+ if (what == MediaPlayer2.CALL_COMPLETED_SEEK_TO && status == 0) {
+ updatePlaybackState();
+ }
+ }
+
private void onPrepared(MediaPlayer2 mp, DataSourceDesc dsd) {
if (DEBUG) {
Log.d(TAG, "OnPreparedListener(). mCurrentState=" + mCurrentState
@@ -1377,7 +1385,6 @@
} else {
mMediaPlayer.seekTo(pos, MediaPlayer2.SEEK_PREVIOUS_SYNC);
mSeekWhenPrepared = 0;
- updatePlaybackState();
}
} else {
mSeekWhenPrepared = pos;