Skip to content

Commit 2075f2d

Browse files
Teng-Hui ZhuAndroid (Google) Code Review
authored andcommitted
Merge "Notify Java side to start when transition into full screen mode without a reload." into jb-dev
2 parents 17b9cec + 6a9586b commit 2075f2d

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

core/java/android/webkit/HTML5VideoFullScreen.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,6 @@ public void onPrepared(MediaPlayer mp) {
194194
mCanPause = mCanSeekBack = mCanSeekForward = true;
195195
}
196196

197-
// mMediaController status depends on the Metadata result, so put it
198-
// after reading the MetaData
199-
if (mMediaController != null) {
200-
mMediaController.setEnabled(true);
201-
mMediaController.show();
202-
}
203-
204197
if (mProgressView != null) {
205198
mProgressView.setVisibility(View.GONE);
206199
}
@@ -215,6 +208,16 @@ public void onPrepared(MediaPlayer mp) {
215208

216209
if (getStartWhenPrepared()) {
217210
mPlayer.start();
211+
// Clear the flag.
212+
setStartWhenPrepared(false);
213+
}
214+
215+
// mMediaController status depends on the Metadata result, so put it
216+
// after reading the MetaData.
217+
// And make sure mPlayer state is updated before showing the controller.
218+
if (mMediaController != null) {
219+
mMediaController.setEnabled(true);
220+
mMediaController.show();
218221
}
219222
}
220223

core/java/android/webkit/HTML5VideoViewProxy.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,29 +147,34 @@ public static void enterFullScreenVideo(int layerId, String url,
147147
// Save the inline video info and inherit it in the full screen
148148
int savePosition = 0;
149149
boolean canSkipPrepare = false;
150+
boolean forceStart = false;
150151
if (mHTML5VideoView != null) {
151152
// We don't allow enter full screen mode while the previous
152153
// full screen video hasn't finished yet.
153154
if (!mHTML5VideoView.fullScreenExited() && mHTML5VideoView.isFullScreenMode()) {
154155
Log.w(LOGTAG, "Try to reenter the full screen mode");
155156
return;
156157
}
158+
int playerState = mHTML5VideoView.getCurrentState();
157159
// If we are playing the same video, then it is better to
158160
// save the current position.
159161
if (layerId == mHTML5VideoView.getVideoLayerId()) {
160162
savePosition = mHTML5VideoView.getCurrentPosition();
161-
int playerState = mHTML5VideoView.getCurrentState();
162163
canSkipPrepare = (playerState == HTML5VideoView.STATE_PREPARING
163164
|| playerState == HTML5VideoView.STATE_PREPARED
164165
|| playerState == HTML5VideoView.STATE_PLAYING)
165166
&& !mHTML5VideoView.isFullScreenMode();
166167
}
167168
if (!canSkipPrepare) {
168169
mHTML5VideoView.reset();
170+
} else {
171+
forceStart = playerState == HTML5VideoView.STATE_PREPARING
172+
|| playerState == HTML5VideoView.STATE_PLAYING;
169173
}
170174
}
171175
mHTML5VideoView = new HTML5VideoFullScreen(proxy.getContext(),
172176
layerId, savePosition, canSkipPrepare);
177+
mHTML5VideoView.setStartWhenPrepared(forceStart);
173178
mCurrentProxy = proxy;
174179
mHTML5VideoView.setVideoURI(url, mCurrentProxy);
175180
mHTML5VideoView.enterFullScreenVideoState(layerId, proxy, webView);

0 commit comments

Comments
 (0)