以下是来自justin.com的流视频或twitch.tv此CHANNEL
转到here并选择任何直播,从中获取网址并添加html://.../hls
在屏幕上出现
伙计们告诉我:
Android很奇怪,它不会在Android Chrome上运行,但会 在股票Android浏览器工作(好吧,以前的股票Android 浏览器现在知道Chrome是股票浏览器)。它也适用于所有人 Safari浏览器。
我已经实现了这段代码
stream = (WebView) findViewById(R.id.webView1);
stream.getSettings().setJavaScriptEnabled(true);
stream.getSettings().setPluginsEnabled(true);
stream.setBackgroundColor(Color.parseColor("#000000"));
stream.getSettings().setUseWideViewPort(true);
stream.setWebViewClient(new HelloWebViewClient());
stream.getSettings().setAppCacheEnabled(true);
stream.getSettings().setDomStorageEnabled(true);
stream.getSettings().setSaveFormData(true);
stream.getSettings().setLoadWithOverviewMode(true);
stream.getSettings().setUseWideViewPort(true);
stream.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
stream.setScrollbarFadingEnabled(false);
stream.loadUrl("http://www.twitch.tv/arteezy/hls");
stream.setVisibility(View.VISIBLE);
private class HelloWebViewClient extends WebViewClient
{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
}
但它会从视频中打开第一张图片并停止缓存......似乎WebView不会缓存视频...... 有什么问题?
已更新
以下代码流仅播放2秒然后停止
stream = (WebView) findViewById(R.id.webView1);
stream.getSettings().setJavaScriptEnabled(true);
stream.getSettings().setJavaScriptEnabled(true);
stream.getSettings().setPluginsEnabled(true);
stream.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
stream.setBackgroundColor(Color.parseColor("#000000"));
stream.getSettings().setUseWideViewPort(true);
// mWebView.loadUrl("data/game.swf");
//mWebViewChat.getSettings().setBuiltInZoomControls(true);
// mWebView.loadUrl("file:///android_asset/live.swf?channel=d2l");
stream.setWebViewClient(new HelloWebViewClient());
final Activity MyActivity = this;
stream.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress)
{
MyActivity.setTitle("Loading...");
MyActivity.setProgress(progress * 100);
if (progress*100 == 100){
stream.clearFormData();
stream.clearHistory();
stream.clearCache(true);
}
}
});
stream.getSettings().setAppCacheEnabled(true);
stream.getSettings().setDomStorageEnabled(true);
stream.getSettings().setSaveFormData(true);
stream.getSettings().setLoadWithOverviewMode(true);
stream.getSettings().setUseWideViewPort(true);
stream.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
stream.setScrollbarFadingEnabled(false);
stream.clearFormData();
stream.clearHistory();
stream.clearCache(true);
stream.getSettings().setAppCacheEnabled(true);
stream.getSettings().setDatabaseEnabled(true);
stream.getSettings().setDomStorageEnabled(true);
stream.getSettings().setPluginsEnabled(true);
stream.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
stream.getSettings().setPluginState(PluginState.ON);
stream.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);// no need I think
stream.getSettings().setLoadWithOverviewMode(true);
stream.getSettings().setUseWideViewPort(true);
stream.getSettings().setBuiltInZoomControls(true);
stream.setInitialScale(1);
stream.setWebChromeClient(new WebChromeClient());
stream.getSettings().setJavaScriptEnabled(true);
stream.getSettings().setPluginsEnabled(true);
stream.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
stream.setBackgroundColor(Color.parseColor("#000000"));
stream.getSettings().setUseWideViewPort(true);
// mWebView.loadUrl("data/game.swf");
//mWebViewChat.getSettings().setBuiltInZoomControls(true);
// mWebView.loadUrl("file:///android_asset/live.swf?channel=d2l");
stream.setWebViewClient(new HelloWebViewClient());
stream.getSettings().setAppCacheEnabled(true);
stream.getSettings().setDomStorageEnabled(true);
stream.getSettings().setSaveFormData(true);
stream.getSettings().setLoadWithOverviewMode(true);
stream.getSettings().setUseWideViewPort(true);
stream.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
stream.setScrollbarFadingEnabled(false);
stream.clearFormData();
stream.clearHistory();
stream.clearCache(true);
stream.getSettings().setAppCacheEnabled(true);
stream.getSettings().setDatabaseEnabled(true);
stream.getSettings().setDomStorageEnabled(true);
stream.loadUrl("http://www.twitch.tv/arteezy/hls");