diff options
author | Teng-Hui Zhu <ztenghui@google.com> | 2012-01-10 16:15:21 -0800 |
---|---|---|
committer | Teng-Hui Zhu <ztenghui@google.com> | 2012-01-10 17:27:56 -0800 |
commit | 299925eb66dc094d5153fb4027be09bc13e139a0 (patch) | |
tree | 3a3f73b02d60d40f062dd145ad2ae054629d614c | |
parent | 506b8bf34a2526eff1ac9fedaa29494a39206888 (diff) | |
download | external_webkit-299925eb66dc094d5153fb4027be09bc13e139a0.zip external_webkit-299925eb66dc094d5153fb4027be09bc13e139a0.tar.gz external_webkit-299925eb66dc094d5153fb4027be09bc13e139a0.tar.bz2 |
Native function to support restore the media player state
nativeRestoreState will call java side to start to play if the native side
think the player is still playing.
Currently used when switching from inline mode to full screen mode.
bug:5765848
framework change:
https://android-git.corp.google.com/g/#/c/157864/
Change-Id: I481584ef8764d0d655f242427daa59335673e6fe
-rw-r--r-- | Source/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h | 1 | ||||
-rw-r--r-- | Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp | 19 |
2 files changed, 20 insertions, 0 deletions
diff --git a/Source/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h b/Source/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h index 404ef08..535e7ae 100644 --- a/Source/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h +++ b/Source/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h @@ -95,6 +95,7 @@ public: virtual void onPosterFetched(SkBitmap*) { } void onBuffering(int percent); void onTimeupdate(int position); + void onRestoreState(); // These following two functions are used to turn on inline video support bool supportsAcceleratedRendering() const { return true; } diff --git a/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp b/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp index 339e91b..7a80925 100644 --- a/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp +++ b/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp @@ -168,6 +168,14 @@ void MediaPlayerPrivate::onEnded() m_networkState = MediaPlayer::Idle; } +void MediaPlayerPrivate::onRestoreState() +{ + if (!m_paused) { + //Kick off a JNI call to start the video. + play(); + } +} + void MediaPlayerPrivate::onPaused() { m_paused = true; @@ -570,6 +578,15 @@ static void OnTimeupdate(JNIEnv* env, jobject obj, int position, int pointer) } } +static void OnRestoreState(JNIEnv* env, jobject obj, int pointer) +{ + if (pointer) { + WebCore::MediaPlayerPrivate* player = reinterpret_cast<WebCore::MediaPlayerPrivate*>(pointer); + player->onRestoreState(); + } +} + + // This is called on the UI thread only. // The video layers are composited on the webkit thread and then copied over // to the UI thread with the same ID. For rendering, we are only using the @@ -632,6 +649,8 @@ static JNINativeMethod g_MediaPlayerMethods[] = { (void*) OnPaused }, { "nativeOnPosterFetched", "(Landroid/graphics/Bitmap;I)V", (void*) OnPosterFetched }, + { "nativeOnRestoreState", "(I)V", + (void*) OnRestoreState }, { "nativeSendSurfaceTexture", "(Landroid/graphics/SurfaceTexture;IIII)Z", (void*) SendSurfaceTexture }, { "nativeOnTimeupdate", "(II)V", |