What happens (under the cover) when I click the Play "button" in YouTube?
- Note 1: This question refers to HTML5 videos only, not Flash videos.
- Note 2: Also, it specifically targets HTML5 video playing on Android.
Given the following HTML5 video in YouTube:
<div id="player">
<video poster="data:image/gif;
base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
src="http://v19.lscache2.c.youtube.com/videoplayback?begin=0&itag=18&
ipbits=0ampsignature=151700E49EA1B695940D89926C1C07CDF0C176F0.B7DE0453C70BFBA0BA644DE7F6BBB72E9EE43B5F&
sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Cratebypass%2Coc%3AU0hPSVRSUl9FSkNOOV9MTFZF&
sver=3&
ratebypass=yes&expire=1304474400&len=265000&key=yt1&ip=0.0.0.0&
id=55884c15b4baba8f&el=home&yms=5602568839599417322&app=youtube_mobile" class="bn" width="1" height="2" id="player_VYhMFbS6uo8">
</video>
</div>
I can identify the src=
attribute as a URL being loaded into... what exactly?
I know that WebView can't play HTML5 videos by itself, so it hands them over to WebChromeClient: When I touch that familiar right-pointing arrow in the middle of the image representing the clip, An开发者_Go百科droid switches automatically to a different activity that plays the video, instead of playing it inside WebView.
Now, I would like to start playing the video in exactly the same manner but from within my app, without the user having to "click" that right-pointing arrow.
I tried to simply hand over that src=
URL (http://v19.lscache2.c.youtube.com/videoplayback?begin...) to WebView, thinking that this would trigger WebChromeClient.onShowCustomView()
just as what happens when I click the right-pointing arrow, but... nothing really happens when I do that.
So, I am wondering: What actually happens, from WebView
and WebChromeClient
point of view, when I click that right-pointing arrow?
What do I need to do in order to "click" that right-pointing arrow?
Update: Thanks to the comment from @dronus I found the following in LogCat (after clicking the play button manually):
05-03 19:35:07.296: INFO/StagefrightPlayer(121):
setDataSource('http://v19.lscache2.c.youtube.com/videoplayback?begin=0
&itag=18
&ipbits=0
&signature=BB85C25344502EF07EC970250EFBF6661098373E.6A7E108FA6F48A0741CDF7A356B0E1474F185195
&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Cratebypass%2Coc%3AU0hPSVRTVl9FSkNOOV9MTVpJ
&sver=3
&ratebypass=yes
&expire=1304488800
&len=265000
&key=yt1
&ip=0.0.0.0
&id=55884c15b4baba8f
&el=watch
&yms=5602637908081220405
&app=youtube_mobile')
The question remains: What triggers this?
I would guesss that an Intent is launched to display the video with the specfied url and all other attributes.
Have you tried to launch an Intent like this with some of the attributes listed as extras for the intent?
Intent tostart = new Intent(Intent.ACTION_VIEW);
tostart.setDataAndType(Uri.parse(movieurl), "video/*");
startActivity(tostart);
精彩评论