Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.webkit; |
| 18 | |
| 19 | import android.content.Context; |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 20 | import android.graphics.Bitmap; |
| 21 | import android.graphics.BitmapFactory; |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 22 | import android.graphics.SurfaceTexture; |
Andrei Popescu | 3c946a1a | 2009-07-03 08:20:53 +0100 | [diff] [blame] | 23 | import android.media.MediaPlayer; |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 24 | import android.net.http.EventHandler; |
| 25 | import android.net.http.Headers; |
| 26 | import android.net.http.RequestHandle; |
| 27 | import android.net.http.RequestQueue; |
| 28 | import android.net.http.SslCertificate; |
| 29 | import android.net.http.SslError; |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 30 | import android.os.Handler; |
| 31 | import android.os.Looper; |
| 32 | import android.os.Message; |
| 33 | import android.util.Log; |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 34 | |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 35 | import java.io.ByteArrayOutputStream; |
| 36 | import java.io.IOException; |
Ben Murdoch | 4250979 | 2011-02-18 12:34:35 +0000 | [diff] [blame] | 37 | import java.net.MalformedURLException; |
| 38 | import java.net.URL; |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 39 | import java.util.HashMap; |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 40 | import java.util.Map; |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 41 | |
| 42 | /** |
Andrei Popescu | 3c946a1a | 2009-07-03 08:20:53 +0100 | [diff] [blame] | 43 | * <p>Proxy for HTML5 video views. |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 44 | */ |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 45 | class HTML5VideoViewProxy extends Handler |
| 46 | implements MediaPlayer.OnPreparedListener, |
Andrei Popescu | 50c8623 | 2009-09-30 16:51:25 +0100 | [diff] [blame] | 47 | MediaPlayer.OnCompletionListener, |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 48 | MediaPlayer.OnErrorListener, |
| 49 | SurfaceTexture.OnFrameAvailableListener { |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 50 | // Logging tag. |
| 51 | private static final String LOGTAG = "HTML5VideoViewProxy"; |
| 52 | |
Andrei Popescu | 3c946a1a | 2009-07-03 08:20:53 +0100 | [diff] [blame] | 53 | // Message Ids for WebCore thread -> UI thread communication. |
Andrei Popescu | 50c8623 | 2009-09-30 16:51:25 +0100 | [diff] [blame] | 54 | private static final int PLAY = 100; |
| 55 | private static final int SEEK = 101; |
| 56 | private static final int PAUSE = 102; |
| 57 | private static final int ERROR = 103; |
| 58 | private static final int LOAD_DEFAULT_POSTER = 104; |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 59 | |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 60 | // Message Ids to be handled on the WebCore thread |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 61 | private static final int PREPARED = 200; |
| 62 | private static final int ENDED = 201; |
Andrei Popescu | 50c8623 | 2009-09-30 16:51:25 +0100 | [diff] [blame] | 63 | private static final int POSTER_FETCHED = 202; |
Shimeng (Simon) Wang | 43aaa2d | 2010-10-18 16:25:59 -0700 | [diff] [blame] | 64 | private static final int PAUSED = 203; |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 65 | |
Andrei Popescu | 048eb3b | 2010-01-11 21:12:54 +0000 | [diff] [blame] | 66 | // Timer thread -> UI thread |
| 67 | private static final int TIMEUPDATE = 300; |
| 68 | |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 69 | // The C++ MediaPlayerPrivateAndroid object. |
| 70 | int mNativePointer; |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 71 | // The handler for WebCore thread messages; |
| 72 | private Handler mWebCoreHandler; |
Andrei Popescu | 3c946a1a | 2009-07-03 08:20:53 +0100 | [diff] [blame] | 73 | // The WebView instance that created this view. |
| 74 | private WebView mWebView; |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 75 | // The poster image to be shown when the video is not playing. |
Andrei Popescu | 50c8623 | 2009-09-30 16:51:25 +0100 | [diff] [blame] | 76 | // This ref prevents the bitmap from being GC'ed. |
| 77 | private Bitmap mPoster; |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 78 | // The poster downloader. |
| 79 | private PosterDownloader mPosterDownloader; |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 80 | // The seek position. |
| 81 | private int mSeekPosition; |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 82 | // A helper class to control the playback. This executes on the UI thread! |
| 83 | private static final class VideoPlayer { |
| 84 | // The proxy that is currently playing (if any). |
| 85 | private static HTML5VideoViewProxy mCurrentProxy; |
| 86 | // The VideoView instance. This is a singleton for now, at least until |
| 87 | // http://b/issue?id=1973663 is fixed. |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 88 | private static HTML5VideoView mHTML5VideoView; |
Andrei Popescu | 048eb3b | 2010-01-11 21:12:54 +0000 | [diff] [blame] | 89 | |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 90 | private static boolean isVideoSelfEnded = false; |
| 91 | // By using the baseLayer and the current video Layer ID, we can |
| 92 | // identify the exact layer on the UI thread to use the SurfaceTexture. |
| 93 | private static int mBaseLayer = 0; |
Andrei Popescu | 3c946a1a | 2009-07-03 08:20:53 +0100 | [diff] [blame] | 94 | |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 95 | // Every time webView setBaseLayer, this will be called. |
| 96 | // When we found the Video layer, then we set the Surface Texture to it. |
| 97 | // Otherwise, we may want to delete the Surface Texture to save memory. |
| 98 | public static void setBaseLayer(int layer) { |
Teng-Hui Zhu | 10ab6549 | 2011-03-16 16:42:32 -0700 | [diff] [blame] | 99 | // Don't do this for full screen mode. |
| 100 | if (mHTML5VideoView != null |
| 101 | && !mHTML5VideoView.isFullScreenMode()) { |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 102 | mBaseLayer = layer; |
| 103 | SurfaceTexture surfTexture = mHTML5VideoView.getSurfaceTexture(); |
| 104 | int textureName = mHTML5VideoView.getTextureName(); |
| 105 | |
| 106 | int currentVideoLayerId = mHTML5VideoView.getVideoLayerId(); |
| 107 | if (layer != 0 && surfTexture != null && currentVideoLayerId != -1) { |
Teng-Hui Zhu | 265db32 | 2011-03-18 14:56:10 -0700 | [diff] [blame^] | 108 | int playerState = mHTML5VideoView.getCurrentState(); |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 109 | boolean foundInTree = nativeSendSurfaceTexture(surfTexture, |
| 110 | layer, currentVideoLayerId, textureName, |
Teng-Hui Zhu | 265db32 | 2011-03-18 14:56:10 -0700 | [diff] [blame^] | 111 | playerState); |
| 112 | if (playerState == HTML5VideoView.STATE_PREPARED |
| 113 | && !foundInTree) { |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 114 | mHTML5VideoView.pauseAndDispatch(mCurrentProxy); |
| 115 | mHTML5VideoView.deleteSurfaceTexture(); |
Andrei Popescu | 31d2aa1 | 2010-04-08 15:19:22 +0100 | [diff] [blame] | 116 | } |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 117 | } |
Andrei Popescu | a41f97b | 2010-01-11 18:36:25 +0000 | [diff] [blame] | 118 | } |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 119 | } |
Andrei Popescu | a41f97b | 2010-01-11 18:36:25 +0000 | [diff] [blame] | 120 | |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 121 | // When a WebView is paused, we also want to pause the video in it. |
| 122 | public static void pauseAndDispatch() { |
| 123 | if (mHTML5VideoView != null) { |
| 124 | mHTML5VideoView.pauseAndDispatch(mCurrentProxy); |
| 125 | // When switching out, clean the video content on the old page |
| 126 | // by telling the layer not readyToUseSurfTex. |
| 127 | setBaseLayer(mBaseLayer); |
| 128 | } |
| 129 | } |
| 130 | |
Teng-Hui Zhu | 10ab6549 | 2011-03-16 16:42:32 -0700 | [diff] [blame] | 131 | public static void enterFullScreenVideo(int layerId, String url, |
| 132 | HTML5VideoViewProxy proxy, WebView webView) { |
| 133 | // Save the inline video info and inherit it in the full screen |
| 134 | int savePosition = 0; |
| 135 | boolean savedIsPlaying = false; |
| 136 | if (mHTML5VideoView != null) { |
| 137 | // If we are playing the same video, then it is better to |
| 138 | // save the current position. |
| 139 | if (layerId == mHTML5VideoView.getVideoLayerId()) { |
| 140 | savePosition = mHTML5VideoView.getCurrentPosition(); |
| 141 | savedIsPlaying = mHTML5VideoView.isPlaying(); |
| 142 | } |
| 143 | mHTML5VideoView.pauseAndDispatch(mCurrentProxy); |
| 144 | mHTML5VideoView.release(); |
| 145 | } |
| 146 | mHTML5VideoView = new HTML5VideoFullScreen(proxy.getContext(), |
| 147 | layerId, savePosition, savedIsPlaying); |
| 148 | mCurrentProxy = proxy; |
| 149 | |
| 150 | mHTML5VideoView.setVideoURI(url, mCurrentProxy); |
| 151 | |
| 152 | mHTML5VideoView.enterFullScreenVideoState(layerId, proxy, webView); |
| 153 | } |
| 154 | |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 155 | // This is on the UI thread. |
| 156 | // When native tell Java to play, we need to check whether or not it is |
| 157 | // still the same video by using videoLayerId and treat it differently. |
| 158 | public static void play(String url, int time, HTML5VideoViewProxy proxy, |
| 159 | WebChromeClient client, int videoLayerId) { |
| 160 | int currentVideoLayerId = -1; |
Teng-Hui Zhu | 10ab6549 | 2011-03-16 16:42:32 -0700 | [diff] [blame] | 161 | boolean backFromFullScreenMode = false; |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 162 | |
Teng-Hui Zhu | 10ab6549 | 2011-03-16 16:42:32 -0700 | [diff] [blame] | 163 | if (mHTML5VideoView != null) { |
| 164 | currentVideoLayerId = mHTML5VideoView.getVideoLayerId(); |
| 165 | if (mHTML5VideoView instanceof HTML5VideoFullScreen) { |
| 166 | backFromFullScreenMode = true; |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | if (backFromFullScreenMode |
| 171 | || currentVideoLayerId != videoLayerId |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 172 | || mHTML5VideoView.getSurfaceTexture() == null) { |
| 173 | // Here, we handle the case when switching to a new video, |
| 174 | // either inside a WebView or across WebViews |
| 175 | // For switching videos within a WebView or across the WebView, |
| 176 | // we need to pause the old one and re-create a new media player |
| 177 | // inside the HTML5VideoView. |
| 178 | if (mHTML5VideoView != null) { |
| 179 | mHTML5VideoView.pauseAndDispatch(mCurrentProxy); |
| 180 | // release the media player to avoid finalize error |
| 181 | mHTML5VideoView.release(); |
| 182 | } |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 183 | mCurrentProxy = proxy; |
Teng-Hui Zhu | 10ab6549 | 2011-03-16 16:42:32 -0700 | [diff] [blame] | 184 | mHTML5VideoView = new HTML5VideoInline(videoLayerId, time, false); |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 185 | |
Teng-Hui Zhu | 10ab6549 | 2011-03-16 16:42:32 -0700 | [diff] [blame] | 186 | mHTML5VideoView.setVideoURI(url, mCurrentProxy); |
| 187 | mHTML5VideoView.prepareDataAndDisplayMode(proxy); |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 188 | } else if (mCurrentProxy == proxy) { |
| 189 | // Here, we handle the case when we keep playing with one video |
| 190 | if (!mHTML5VideoView.isPlaying()) { |
| 191 | mHTML5VideoView.seekTo(time); |
| 192 | mHTML5VideoView.start(); |
| 193 | } |
| 194 | } else if (mCurrentProxy != null) { |
Teng-Hui Zhu | 10ab6549 | 2011-03-16 16:42:32 -0700 | [diff] [blame] | 195 | // Some other video is already playing. Notify the caller that |
| 196 | // its playback ended. |
Andrei Popescu | c4fbceb | 2010-04-14 13:30:23 +0100 | [diff] [blame] | 197 | proxy.dispatchOnEnded(); |
Andrei Popescu | 3c946a1a | 2009-07-03 08:20:53 +0100 | [diff] [blame] | 198 | } |
Andrei Popescu | 3c946a1a | 2009-07-03 08:20:53 +0100 | [diff] [blame] | 199 | } |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 200 | |
Andrei Popescu | 048eb3b | 2010-01-11 21:12:54 +0000 | [diff] [blame] | 201 | public static boolean isPlaying(HTML5VideoViewProxy proxy) { |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 202 | return (mCurrentProxy == proxy && mHTML5VideoView != null |
| 203 | && mHTML5VideoView.isPlaying()); |
Andrei Popescu | 048eb3b | 2010-01-11 21:12:54 +0000 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | public static int getCurrentPosition() { |
| 207 | int currentPosMs = 0; |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 208 | if (mHTML5VideoView != null) { |
| 209 | currentPosMs = mHTML5VideoView.getCurrentPosition(); |
Andrei Popescu | 048eb3b | 2010-01-11 21:12:54 +0000 | [diff] [blame] | 210 | } |
| 211 | return currentPosMs; |
| 212 | } |
| 213 | |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 214 | public static void seek(int time, HTML5VideoViewProxy proxy) { |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 215 | if (mCurrentProxy == proxy && time >= 0 && mHTML5VideoView != null) { |
| 216 | mHTML5VideoView.seekTo(time); |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 217 | } |
| 218 | } |
| 219 | |
| 220 | public static void pause(HTML5VideoViewProxy proxy) { |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 221 | if (mCurrentProxy == proxy && mHTML5VideoView != null) { |
| 222 | mHTML5VideoView.pause(); |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 223 | } |
| 224 | } |
Andrei Popescu | bf385d7 | 2009-09-18 18:59:52 +0100 | [diff] [blame] | 225 | |
| 226 | public static void onPrepared() { |
Teng-Hui Zhu | 10ab6549 | 2011-03-16 16:42:32 -0700 | [diff] [blame] | 227 | if (!mHTML5VideoView.isFullScreenMode() || |
| 228 | mHTML5VideoView.isFullScreenMode() && |
| 229 | mHTML5VideoView.getAutostart() ) |
| 230 | mHTML5VideoView.start(); |
Teng-Hui Zhu | 265db32 | 2011-03-18 14:56:10 -0700 | [diff] [blame^] | 231 | if (mBaseLayer != 0) { |
| 232 | setBaseLayer(mBaseLayer); |
| 233 | } |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | public static void end() { |
| 237 | if (mCurrentProxy != null) { |
| 238 | if (isVideoSelfEnded) |
| 239 | mCurrentProxy.dispatchOnEnded(); |
| 240 | else |
| 241 | mCurrentProxy.dispatchOnPaused(); |
| 242 | } |
| 243 | isVideoSelfEnded = false; |
Andrei Popescu | bf385d7 | 2009-09-18 18:59:52 +0100 | [diff] [blame] | 244 | } |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | // A bunch event listeners for our VideoView |
| 248 | // MediaPlayer.OnPreparedListener |
| 249 | public void onPrepared(MediaPlayer mp) { |
Andrei Popescu | bf385d7 | 2009-09-18 18:59:52 +0100 | [diff] [blame] | 250 | VideoPlayer.onPrepared(); |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 251 | Message msg = Message.obtain(mWebCoreHandler, PREPARED); |
| 252 | Map<String, Object> map = new HashMap<String, Object>(); |
| 253 | map.put("dur", new Integer(mp.getDuration())); |
| 254 | map.put("width", new Integer(mp.getVideoWidth())); |
| 255 | map.put("height", new Integer(mp.getVideoHeight())); |
| 256 | msg.obj = map; |
| 257 | mWebCoreHandler.sendMessage(msg); |
| 258 | } |
| 259 | |
| 260 | // MediaPlayer.OnCompletionListener; |
| 261 | public void onCompletion(MediaPlayer mp) { |
Andrei Popescu | c4fbceb | 2010-04-14 13:30:23 +0100 | [diff] [blame] | 262 | // The video ended by itself, so we need to |
| 263 | // send a message to the UI thread to dismiss |
| 264 | // the video view and to return to the WebView. |
Shimeng (Simon) Wang | 43aaa2d | 2010-10-18 16:25:59 -0700 | [diff] [blame] | 265 | // arg1 == 1 means the video ends by itself. |
| 266 | sendMessage(obtainMessage(ENDED, 1, 0)); |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 267 | } |
| 268 | |
Andrei Popescu | 50c8623 | 2009-09-30 16:51:25 +0100 | [diff] [blame] | 269 | // MediaPlayer.OnErrorListener |
| 270 | public boolean onError(MediaPlayer mp, int what, int extra) { |
| 271 | sendMessage(obtainMessage(ERROR)); |
| 272 | return false; |
| 273 | } |
| 274 | |
Andrei Popescu | c4fbceb | 2010-04-14 13:30:23 +0100 | [diff] [blame] | 275 | public void dispatchOnEnded() { |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 276 | Message msg = Message.obtain(mWebCoreHandler, ENDED); |
| 277 | mWebCoreHandler.sendMessage(msg); |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 278 | } |
Andrei Popescu | 3c946a1a | 2009-07-03 08:20:53 +0100 | [diff] [blame] | 279 | |
Shimeng (Simon) Wang | 43aaa2d | 2010-10-18 16:25:59 -0700 | [diff] [blame] | 280 | public void dispatchOnPaused() { |
| 281 | Message msg = Message.obtain(mWebCoreHandler, PAUSED); |
| 282 | mWebCoreHandler.sendMessage(msg); |
| 283 | } |
| 284 | |
Andrei Popescu | 048eb3b | 2010-01-11 21:12:54 +0000 | [diff] [blame] | 285 | public void onTimeupdate() { |
| 286 | sendMessage(obtainMessage(TIMEUPDATE)); |
| 287 | } |
| 288 | |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 289 | // When there is a frame ready from surface texture, we should tell WebView |
| 290 | // to refresh. |
| 291 | @Override |
| 292 | public void onFrameAvailable(SurfaceTexture surfaceTexture) { |
| 293 | // TODO: This should support partial invalidation too. |
| 294 | mWebView.invalidate(); |
| 295 | } |
| 296 | |
Andrei Popescu | 048eb3b | 2010-01-11 21:12:54 +0000 | [diff] [blame] | 297 | // Handler for the messages from WebCore or Timer thread to the UI thread. |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 298 | @Override |
| 299 | public void handleMessage(Message msg) { |
| 300 | // This executes on the UI thread. |
| 301 | switch (msg.what) { |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 302 | case PLAY: { |
| 303 | String url = (String) msg.obj; |
| 304 | WebChromeClient client = mWebView.getWebChromeClient(); |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 305 | int videoLayerID = msg.arg1; |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 306 | if (client != null) { |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 307 | VideoPlayer.play(url, mSeekPosition, this, client, videoLayerID); |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 308 | } |
| 309 | break; |
| 310 | } |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 311 | case SEEK: { |
| 312 | Integer time = (Integer) msg.obj; |
| 313 | mSeekPosition = time; |
| 314 | VideoPlayer.seek(mSeekPosition, this); |
| 315 | break; |
| 316 | } |
| 317 | case PAUSE: { |
| 318 | VideoPlayer.pause(this); |
| 319 | break; |
| 320 | } |
Andrei Popescu | 46a83b4 | 2009-10-23 13:49:46 +0100 | [diff] [blame] | 321 | case ENDED: |
Shimeng (Simon) Wang | 43aaa2d | 2010-10-18 16:25:59 -0700 | [diff] [blame] | 322 | if (msg.arg1 == 1) |
| 323 | VideoPlayer.isVideoSelfEnded = true; |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 324 | VideoPlayer.end(); |
| 325 | break; |
Andrei Popescu | 50c8623 | 2009-09-30 16:51:25 +0100 | [diff] [blame] | 326 | case ERROR: { |
| 327 | WebChromeClient client = mWebView.getWebChromeClient(); |
| 328 | if (client != null) { |
| 329 | client.onHideCustomView(); |
| 330 | } |
| 331 | break; |
| 332 | } |
| 333 | case LOAD_DEFAULT_POSTER: { |
| 334 | WebChromeClient client = mWebView.getWebChromeClient(); |
| 335 | if (client != null) { |
| 336 | doSetPoster(client.getDefaultVideoPoster()); |
| 337 | } |
| 338 | break; |
| 339 | } |
Andrei Popescu | 048eb3b | 2010-01-11 21:12:54 +0000 | [diff] [blame] | 340 | case TIMEUPDATE: { |
| 341 | if (VideoPlayer.isPlaying(this)) { |
| 342 | sendTimeupdate(); |
| 343 | } |
| 344 | break; |
| 345 | } |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 346 | } |
| 347 | } |
| 348 | |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 349 | // Everything below this comment executes on the WebCore thread, except for |
| 350 | // the EventHandler methods, which are called on the network thread. |
| 351 | |
| 352 | // A helper class that knows how to download posters |
| 353 | private static final class PosterDownloader implements EventHandler { |
| 354 | // The request queue. This is static as we have one queue for all posters. |
| 355 | private static RequestQueue mRequestQueue; |
| 356 | private static int mQueueRefCount = 0; |
| 357 | // The poster URL |
Ben Murdoch | 4250979 | 2011-02-18 12:34:35 +0000 | [diff] [blame] | 358 | private URL mUrl; |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 359 | // The proxy we're doing this for. |
| 360 | private final HTML5VideoViewProxy mProxy; |
| 361 | // The poster bytes. We only touch this on the network thread. |
| 362 | private ByteArrayOutputStream mPosterBytes; |
| 363 | // The request handle. We only touch this on the WebCore thread. |
| 364 | private RequestHandle mRequestHandle; |
| 365 | // The response status code. |
| 366 | private int mStatusCode; |
| 367 | // The response headers. |
| 368 | private Headers mHeaders; |
| 369 | // The handler to handle messages on the WebCore thread. |
| 370 | private Handler mHandler; |
| 371 | |
| 372 | public PosterDownloader(String url, HTML5VideoViewProxy proxy) { |
Ben Murdoch | 4250979 | 2011-02-18 12:34:35 +0000 | [diff] [blame] | 373 | try { |
| 374 | mUrl = new URL(url); |
| 375 | } catch (MalformedURLException e) { |
| 376 | mUrl = null; |
| 377 | } |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 378 | mProxy = proxy; |
| 379 | mHandler = new Handler(); |
| 380 | } |
| 381 | // Start the download. Called on WebCore thread. |
| 382 | public void start() { |
| 383 | retainQueue(); |
Ben Murdoch | 4250979 | 2011-02-18 12:34:35 +0000 | [diff] [blame] | 384 | |
| 385 | if (mUrl == null) { |
| 386 | return; |
| 387 | } |
| 388 | |
| 389 | // Only support downloading posters over http/https. |
| 390 | // FIXME: Add support for other schemes. WebKit seems able to load |
| 391 | // posters over other schemes e.g. file://, but gets the dimensions wrong. |
| 392 | String protocol = mUrl.getProtocol(); |
| 393 | if ("http".equals(protocol) || "https".equals(protocol)) { |
| 394 | mRequestHandle = mRequestQueue.queueRequest(mUrl.toString(), "GET", null, |
| 395 | this, null, 0); |
| 396 | } |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 397 | } |
| 398 | // Cancel the download if active and release the queue. Called on WebCore thread. |
| 399 | public void cancelAndReleaseQueue() { |
| 400 | if (mRequestHandle != null) { |
| 401 | mRequestHandle.cancel(); |
| 402 | mRequestHandle = null; |
| 403 | } |
| 404 | releaseQueue(); |
| 405 | } |
| 406 | // EventHandler methods. Executed on the network thread. |
| 407 | public void status(int major_version, |
| 408 | int minor_version, |
| 409 | int code, |
| 410 | String reason_phrase) { |
| 411 | mStatusCode = code; |
Andrei Popescu | 3c946a1a | 2009-07-03 08:20:53 +0100 | [diff] [blame] | 412 | } |
| 413 | |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 414 | public void headers(Headers headers) { |
| 415 | mHeaders = headers; |
| 416 | } |
| 417 | |
| 418 | public void data(byte[] data, int len) { |
| 419 | if (mPosterBytes == null) { |
| 420 | mPosterBytes = new ByteArrayOutputStream(); |
| 421 | } |
| 422 | mPosterBytes.write(data, 0, len); |
| 423 | } |
| 424 | |
| 425 | public void endData() { |
| 426 | if (mStatusCode == 200) { |
| 427 | if (mPosterBytes.size() > 0) { |
| 428 | Bitmap poster = BitmapFactory.decodeByteArray( |
| 429 | mPosterBytes.toByteArray(), 0, mPosterBytes.size()); |
Andrei Popescu | 50c8623 | 2009-09-30 16:51:25 +0100 | [diff] [blame] | 430 | mProxy.doSetPoster(poster); |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 431 | } |
| 432 | cleanup(); |
| 433 | } else if (mStatusCode >= 300 && mStatusCode < 400) { |
| 434 | // We have a redirect. |
Ben Murdoch | 4250979 | 2011-02-18 12:34:35 +0000 | [diff] [blame] | 435 | try { |
| 436 | mUrl = new URL(mHeaders.getLocation()); |
| 437 | } catch (MalformedURLException e) { |
| 438 | mUrl = null; |
| 439 | } |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 440 | if (mUrl != null) { |
| 441 | mHandler.post(new Runnable() { |
| 442 | public void run() { |
| 443 | if (mRequestHandle != null) { |
Ben Murdoch | 4250979 | 2011-02-18 12:34:35 +0000 | [diff] [blame] | 444 | mRequestHandle.setupRedirect(mUrl.toString(), mStatusCode, |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 445 | new HashMap<String, String>()); |
| 446 | } |
| 447 | } |
| 448 | }); |
| 449 | } |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | public void certificate(SslCertificate certificate) { |
| 454 | // Don't care. |
| 455 | } |
| 456 | |
| 457 | public void error(int id, String description) { |
| 458 | cleanup(); |
| 459 | } |
| 460 | |
| 461 | public boolean handleSslErrorRequest(SslError error) { |
| 462 | // Don't care. If this happens, data() will never be called so |
| 463 | // mPosterBytes will never be created, so no need to call cleanup. |
| 464 | return false; |
| 465 | } |
| 466 | // Tears down the poster bytes stream. Called on network thread. |
| 467 | private void cleanup() { |
| 468 | if (mPosterBytes != null) { |
| 469 | try { |
| 470 | mPosterBytes.close(); |
| 471 | } catch (IOException ignored) { |
| 472 | // Ignored. |
| 473 | } finally { |
| 474 | mPosterBytes = null; |
| 475 | } |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | // Queue management methods. Called on WebCore thread. |
| 480 | private void retainQueue() { |
| 481 | if (mRequestQueue == null) { |
| 482 | mRequestQueue = new RequestQueue(mProxy.getContext()); |
| 483 | } |
| 484 | mQueueRefCount++; |
| 485 | } |
| 486 | |
| 487 | private void releaseQueue() { |
| 488 | if (mQueueRefCount == 0) { |
| 489 | return; |
| 490 | } |
| 491 | if (--mQueueRefCount == 0) { |
| 492 | mRequestQueue.shutdown(); |
| 493 | mRequestQueue = null; |
| 494 | } |
Andrei Popescu | 3c946a1a | 2009-07-03 08:20:53 +0100 | [diff] [blame] | 495 | } |
| 496 | } |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 497 | |
| 498 | /** |
| 499 | * Private constructor. |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 500 | * @param webView is the WebView that hosts the video. |
| 501 | * @param nativePtr is the C++ pointer to the MediaPlayerPrivate object. |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 502 | */ |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 503 | private HTML5VideoViewProxy(WebView webView, int nativePtr) { |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 504 | // This handler is for the main (UI) thread. |
| 505 | super(Looper.getMainLooper()); |
Andrei Popescu | 3c946a1a | 2009-07-03 08:20:53 +0100 | [diff] [blame] | 506 | // Save the WebView object. |
| 507 | mWebView = webView; |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 508 | // Pass Proxy into webview, such that every time we have a setBaseLayer |
| 509 | // call, we tell this Proxy to call the native to update the layer tree |
| 510 | // for the Video Layer's surface texture info |
| 511 | mWebView.setHTML5VideoViewProxy(this); |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 512 | // Save the native ptr |
| 513 | mNativePointer = nativePtr; |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 514 | // create the message handler for this thread |
| 515 | createWebCoreHandler(); |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 516 | } |
| 517 | |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 518 | private void createWebCoreHandler() { |
| 519 | mWebCoreHandler = new Handler() { |
| 520 | @Override |
| 521 | public void handleMessage(Message msg) { |
| 522 | switch (msg.what) { |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 523 | case PREPARED: { |
| 524 | Map<String, Object> map = (Map<String, Object>) msg.obj; |
| 525 | Integer duration = (Integer) map.get("dur"); |
| 526 | Integer width = (Integer) map.get("width"); |
| 527 | Integer height = (Integer) map.get("height"); |
| 528 | nativeOnPrepared(duration.intValue(), width.intValue(), |
| 529 | height.intValue(), mNativePointer); |
| 530 | break; |
| 531 | } |
| 532 | case ENDED: |
Ben Murdoch | ff19d19 | 2011-01-17 18:08:56 +0000 | [diff] [blame] | 533 | mSeekPosition = 0; |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 534 | nativeOnEnded(mNativePointer); |
| 535 | break; |
Shimeng (Simon) Wang | 43aaa2d | 2010-10-18 16:25:59 -0700 | [diff] [blame] | 536 | case PAUSED: |
| 537 | nativeOnPaused(mNativePointer); |
| 538 | break; |
Andrei Popescu | 50c8623 | 2009-09-30 16:51:25 +0100 | [diff] [blame] | 539 | case POSTER_FETCHED: |
| 540 | Bitmap poster = (Bitmap) msg.obj; |
| 541 | nativeOnPosterFetched(poster, mNativePointer); |
| 542 | break; |
Andrei Popescu | 048eb3b | 2010-01-11 21:12:54 +0000 | [diff] [blame] | 543 | case TIMEUPDATE: |
| 544 | nativeOnTimeupdate(msg.arg1, mNativePointer); |
| 545 | break; |
Andrei Popescu | 3c946a1a | 2009-07-03 08:20:53 +0100 | [diff] [blame] | 546 | } |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 547 | } |
| 548 | }; |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 549 | } |
| 550 | |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 551 | private void doSetPoster(Bitmap poster) { |
| 552 | if (poster == null) { |
| 553 | return; |
| 554 | } |
Andrei Popescu | 50c8623 | 2009-09-30 16:51:25 +0100 | [diff] [blame] | 555 | // Save a ref to the bitmap and send it over to the WebCore thread. |
| 556 | mPoster = poster; |
| 557 | Message msg = Message.obtain(mWebCoreHandler, POSTER_FETCHED); |
| 558 | msg.obj = poster; |
| 559 | mWebCoreHandler.sendMessage(msg); |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 560 | } |
| 561 | |
Andrei Popescu | 048eb3b | 2010-01-11 21:12:54 +0000 | [diff] [blame] | 562 | private void sendTimeupdate() { |
| 563 | Message msg = Message.obtain(mWebCoreHandler, TIMEUPDATE); |
| 564 | msg.arg1 = VideoPlayer.getCurrentPosition(); |
| 565 | mWebCoreHandler.sendMessage(msg); |
| 566 | } |
| 567 | |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 568 | public Context getContext() { |
| 569 | return mWebView.getContext(); |
| 570 | } |
| 571 | |
| 572 | // The public methods below are all called from WebKit only. |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 573 | /** |
| 574 | * Play a video stream. |
| 575 | * @param url is the URL of the video stream. |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 576 | */ |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 577 | public void play(String url, int position, int videoLayerID) { |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 578 | if (url == null) { |
| 579 | return; |
| 580 | } |
Ben Murdoch | ff19d19 | 2011-01-17 18:08:56 +0000 | [diff] [blame] | 581 | |
| 582 | if (position > 0) { |
| 583 | seek(position); |
| 584 | } |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 585 | Message message = obtainMessage(PLAY); |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 586 | message.arg1 = videoLayerID; |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 587 | message.obj = url; |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 588 | sendMessage(message); |
| 589 | } |
| 590 | |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 591 | /** |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 592 | * Seek into the video stream. |
| 593 | * @param time is the position in the video stream. |
| 594 | */ |
| 595 | public void seek(int time) { |
| 596 | Message message = obtainMessage(SEEK); |
| 597 | message.obj = new Integer(time); |
| 598 | sendMessage(message); |
| 599 | } |
| 600 | |
| 601 | /** |
| 602 | * Pause the playback. |
| 603 | */ |
| 604 | public void pause() { |
| 605 | Message message = obtainMessage(PAUSE); |
| 606 | sendMessage(message); |
| 607 | } |
| 608 | |
| 609 | /** |
Andrei Popescu | 50c8623 | 2009-09-30 16:51:25 +0100 | [diff] [blame] | 610 | * Tear down this proxy object. |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 611 | */ |
Andrei Popescu | 50c8623 | 2009-09-30 16:51:25 +0100 | [diff] [blame] | 612 | public void teardown() { |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 613 | // This is called by the C++ MediaPlayerPrivate dtor. |
| 614 | // Cancel any active poster download. |
| 615 | if (mPosterDownloader != null) { |
| 616 | mPosterDownloader.cancelAndReleaseQueue(); |
| 617 | } |
Andrei Popescu | 50c8623 | 2009-09-30 16:51:25 +0100 | [diff] [blame] | 618 | mNativePointer = 0; |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 619 | } |
| 620 | |
| 621 | /** |
| 622 | * Load the poster image. |
| 623 | * @param url is the URL of the poster image. |
| 624 | */ |
| 625 | public void loadPoster(String url) { |
| 626 | if (url == null) { |
Andrei Popescu | 50c8623 | 2009-09-30 16:51:25 +0100 | [diff] [blame] | 627 | Message message = obtainMessage(LOAD_DEFAULT_POSTER); |
| 628 | sendMessage(message); |
Andrei Popescu | 64b86a1 | 2009-09-15 20:34:18 +0100 | [diff] [blame] | 629 | return; |
| 630 | } |
| 631 | // Cancel any active poster download. |
| 632 | if (mPosterDownloader != null) { |
| 633 | mPosterDownloader.cancelAndReleaseQueue(); |
| 634 | } |
| 635 | // Load the poster asynchronously |
| 636 | mPosterDownloader = new PosterDownloader(url, this); |
| 637 | mPosterDownloader.start(); |
Patrick Scott | 0a5ce01 | 2009-07-02 08:56:10 -0400 | [diff] [blame] | 638 | } |
| 639 | |
Teng-Hui Zhu | 10ab6549 | 2011-03-16 16:42:32 -0700 | [diff] [blame] | 640 | // These three function are called from UI thread only by WebView. |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 641 | public void setBaseLayer(int layer) { |
| 642 | VideoPlayer.setBaseLayer(layer); |
| 643 | } |
| 644 | |
| 645 | public void pauseAndDispatch() { |
| 646 | VideoPlayer.pauseAndDispatch(); |
| 647 | } |
Teng-Hui Zhu | 10ab6549 | 2011-03-16 16:42:32 -0700 | [diff] [blame] | 648 | |
| 649 | public void enterFullScreenVideo(int layerId, String url) { |
| 650 | VideoPlayer.enterFullScreenVideo(layerId, url, this, mWebView); |
| 651 | } |
| 652 | |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 653 | /** |
Andrei Popescu | 3c946a1a | 2009-07-03 08:20:53 +0100 | [diff] [blame] | 654 | * The factory for HTML5VideoViewProxy instances. |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 655 | * @param webViewCore is the WebViewCore that is requesting the proxy. |
| 656 | * |
Andrei Popescu | 3c946a1a | 2009-07-03 08:20:53 +0100 | [diff] [blame] | 657 | * @return a new HTML5VideoViewProxy object. |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 658 | */ |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 659 | public static HTML5VideoViewProxy getInstance(WebViewCore webViewCore, int nativePtr) { |
| 660 | return new HTML5VideoViewProxy(webViewCore.getWebView(), nativePtr); |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 661 | } |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 662 | |
Ben Murdoch | 1708ad5 | 2010-11-11 15:56:16 +0000 | [diff] [blame] | 663 | /* package */ WebView getWebView() { |
| 664 | return mWebView; |
| 665 | } |
| 666 | |
Andrei Popescu | 290c34a | 2009-09-17 15:55:24 +0100 | [diff] [blame] | 667 | private native void nativeOnPrepared(int duration, int width, int height, int nativePointer); |
| 668 | private native void nativeOnEnded(int nativePointer); |
Shimeng (Simon) Wang | 43aaa2d | 2010-10-18 16:25:59 -0700 | [diff] [blame] | 669 | private native void nativeOnPaused(int nativePointer); |
Andrei Popescu | 50c8623 | 2009-09-30 16:51:25 +0100 | [diff] [blame] | 670 | private native void nativeOnPosterFetched(Bitmap poster, int nativePointer); |
Andrei Popescu | 048eb3b | 2010-01-11 21:12:54 +0000 | [diff] [blame] | 671 | private native void nativeOnTimeupdate(int position, int nativePointer); |
Teng-Hui Zhu | 661e8b1 | 2011-03-02 15:09:34 -0800 | [diff] [blame] | 672 | private native static boolean nativeSendSurfaceTexture(SurfaceTexture texture, |
| 673 | int baseLayer, int videoLayerId, int textureName, |
Teng-Hui Zhu | 265db32 | 2011-03-18 14:56:10 -0700 | [diff] [blame^] | 674 | int playerState); |
Andrei Popescu | 6fa2958 | 2009-06-19 14:54:09 +0100 | [diff] [blame] | 675 | } |