diff options
| -rw-r--r-- | WebCore/html/HTMLMediaElement.cpp | 10 | ||||
| -rw-r--r-- | WebCore/platform/graphics/MediaPlayer.cpp | 16 | ||||
| -rw-r--r-- | WebCore/platform/graphics/MediaPlayer.h | 5 | ||||
| -rw-r--r-- | WebCore/platform/graphics/MediaPlayerPrivate.h | 5 | ||||
| -rw-r--r-- | WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h | 3 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp | 15 |
6 files changed, 49 insertions, 5 deletions
diff --git a/WebCore/html/HTMLMediaElement.cpp b/WebCore/html/HTMLMediaElement.cpp index b2e6428..17a3110 100644 --- a/WebCore/html/HTMLMediaElement.cpp +++ b/WebCore/html/HTMLMediaElement.cpp @@ -554,7 +554,15 @@ void HTMLMediaElement::loadResource(const KURL& url, ContentType& contentType) updateVolume(); m_player->load(m_currentSrc, contentType); - + +#if PLATFORM(ANDROID) + if (isVideo() && m_player->canLoadPoster()) { + KURL posterUrl = static_cast<HTMLVideoElement*>(this)->poster(); + if (!posterUrl.isEmpty()) + m_player->setPoster(posterUrl); + } +#endif + if (renderer()) renderer()->updateFromElement(); } diff --git a/WebCore/platform/graphics/MediaPlayer.cpp b/WebCore/platform/graphics/MediaPlayer.cpp index 6205a7b..15815dc 100644 --- a/WebCore/platform/graphics/MediaPlayer.cpp +++ b/WebCore/platform/graphics/MediaPlayer.cpp @@ -104,6 +104,11 @@ public: virtual void paint(GraphicsContext*, const IntRect&) { } +#if PLATFORM(ANDROID) + virtual bool canLoadPoster() const { return false; } + virtual void setPoster(const String&) { } +#endif + #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) virtual void setPoster(const String& /*url*/) { } virtual void deliverNotification(MediaPlayerProxyNotificationType) { } @@ -253,11 +258,18 @@ void MediaPlayer::load(const String& url, const ContentType& contentType) m_private.set(createNullMediaPlayer(this)); } -#if ENABLE(PLUGIN_PROXY_FOR_VIDEO) +#if PLATFORM(ANDROID) +bool MediaPlayer::canLoadPoster() const +{ + return m_private->canLoadPoster(); +} +#endif + +#if ENABLE(PLUGIN_PROXY_FOR_VIDEO) || PLATFORM(ANDROID) void MediaPlayer::setPoster(const String& url) { m_private->setPoster(url); -} +} #endif void MediaPlayer::cancelLoad() diff --git a/WebCore/platform/graphics/MediaPlayer.h b/WebCore/platform/graphics/MediaPlayer.h index 7f5f2a0..1cb7625 100644 --- a/WebCore/platform/graphics/MediaPlayer.h +++ b/WebCore/platform/graphics/MediaPlayer.h @@ -184,6 +184,11 @@ public: MediaPlayerClient* mediaPlayerClient() const { return m_mediaPlayerClient; } +#if PLATFORM(ANDROID) + bool canLoadPoster() const; + void setPoster(const String&); +#endif + #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) void setPoster(const String& url); void deliverNotification(MediaPlayerProxyNotificationType notification); diff --git a/WebCore/platform/graphics/MediaPlayerPrivate.h b/WebCore/platform/graphics/MediaPlayerPrivate.h index 6d1359b..ba0f4b0 100644 --- a/WebCore/platform/graphics/MediaPlayerPrivate.h +++ b/WebCore/platform/graphics/MediaPlayerPrivate.h @@ -92,6 +92,11 @@ public: virtual void setAutobuffer(bool) { }; +#if PLATFORM(ANDROID) + virtual bool canLoadPoster() const { return false; } + virtual void setPoster(const String&) { } +#endif + #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) virtual void setPoster(const String& url) = 0; virtual void deliverNotification(MediaPlayerProxyNotificationType) = 0; diff --git a/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h b/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h index 7dcb60d..1dbd20b 100644 --- a/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h +++ b/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h @@ -77,6 +77,9 @@ public: virtual void setSize(const IntSize&); + virtual bool canLoadPoster() const { return true; } + virtual void setPoster(const String&); + virtual void paint(GraphicsContext*, const IntRect&); private: // Android-specific methods and fields. diff --git a/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp b/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp index 2465e29..d6362d0 100644 --- a/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp +++ b/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp @@ -47,6 +47,7 @@ struct MediaPlayerPrivate::JavaGlue jmethodID m_createView; jmethodID m_attachView; jmethodID m_removeView; + jmethodID m_setPoster; }; MediaPlayerPrivate::~MediaPlayerPrivate() @@ -99,8 +100,6 @@ void MediaPlayerPrivate::play() if (!frameView) return; - WebViewCore* webViewCore = WebViewCore::getWebViewCore(frameView); - ASSERT(webViewCore); jstring jUrl = env->NewString((unsigned short *)m_url.characters(), m_url.length()); env->CallVoidMethod(m_glue->m_javaProxy, m_glue->m_play, jUrl); env->DeleteLocalRef(jUrl); @@ -200,6 +199,17 @@ void MediaPlayerPrivate::setSize(const IntSize&) { } +void MediaPlayerPrivate::setPoster(const String& url) +{ + JNIEnv* env = JSC::Bindings::getJNIEnv(); + if (!env) + return; + jstring jUrl = env->NewString((unsigned short *)url.characters(), url.length()); + env->CallVoidMethod(m_glue->m_javaProxy, m_glue->m_setPoster, jUrl); + env->DeleteLocalRef(jUrl); + checkException(env); +} + void MediaPlayerPrivate::paint(GraphicsContext*, const IntRect& r) { createJavaPlayerIfNeeded(); @@ -242,6 +252,7 @@ MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player) : m_player(player), m_glue->m_createView = env->GetMethodID(clazz, "createView", "()V"); m_glue->m_attachView = env->GetMethodID(clazz, "attachView", "(IIII)V"); m_glue->m_removeView = env->GetMethodID(clazz, "removeView", "()V"); + m_glue->m_setPoster = env->GetMethodID(clazz, "loadPoster", "(Ljava/lang/String;)V"); m_glue->m_javaProxy = NULL; env->DeleteLocalRef(clazz); // An exception is raised if any of the above fails. |
