我想使用webView来包含Twitch WebPlayer。但当我启动应用时,玩家却不想启动(游戏邦注:twitch定义了我们是否需要使用flash或HTML5播放器)。我的应用启动HTML5播放器,但它在加载,加载,加载……她不能启动流。
wv = (WebView) rootView.findViewById(R.id.webView);
WebSettings webSettings = wv.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
// Load the Twitch Stream you want
// Actually, this is the most important line if code
// The "embed" searches for the suitable stream format
wv.loadUrl("http://www.twitch.tv/MyChannel/embed");
(如果你想尝试,通道示例:gaminglol)
如果我尝试与OgamingLoL,在我的logcat我有:
08-24 15:30:00.546 19102-19102/com.xx I/chromium﹕ [INFO:CONSOLE(0)] "XMLHttpRequest cannot load chrome-extension://boadgeojelhgndaghljhdicfkmllpafd/cast_sender.js. Cross origin requests are only supported for protocol schemes: http, data, https.", source: http://www.twitch.tv/OgamingLoL/embed (0)
08-24 15:30:00.546 19102-19102/com.xx I/chromium﹕ [INFO:CONSOLE(0)] "XMLHttpRequest cannot load chrome-extension://dliochdbjfkdbacpmhlcpmleaejidimm/cast_sender.js. Cross origin requests are only supported for protocol schemes: http, data, https.", source: http://www.twitch.tv/OgamingLoL/embed (0)
08-24 15:30:00.547 19102-19102/com.xx I/chromium﹕ [INFO:CONSOLE(0)] "XMLHttpRequest cannot load chrome-extension://hfaagokkkhdbgiakmmlclaapfelnkoah/cast_sender.js. Cross origin requests are only supported for protocol schemes: http, data, https.", source: http://www.twitch.tv/OgamingLoL/embed (0)
08-24 15:30:00.547 19102-19102/com.xx I/chromium﹕ [INFO:CONSOLE(0)] "XMLHttpRequest cannot load chrome-extension://fmfcbgogabcbclcofgocippekhfcmgfj/cast_sender.js. Cross origin requests are only supported for protocol schemes: http, data, https.", source: http://www.twitch.tv/OgamingLoL/embed (0)
08-24 15:30:00.547 19102-19102/com.xx I/chromium﹕ [INFO:CONSOLE(0)] "XMLHttpRequest cannot load chrome-extension://enhhojjnijigcajfphajepfemndkmdlo/cast_sender.js. Cross origin requests are only supported for protocol schemes: http, data, https.", source: http://www.twitch.tv/OgamingLoL/embed (0)
我试着得到结果,但是我没有看到它…
你能帮我吗? =)
谢谢你,祝你有一个美好的一天:p
编辑:http://ahmed.amayem.com/solution-to-chrome-cross-origin-requests-are-only-supported-for-protocol-schemes-http-data-chrome-chrome-extension-https-chrome-extension-resource/(那帮不了我)
try this:
// settings for webview
mWebView = (WebView)findViewById(R.id.activity_main_webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginState(PluginState.ON);
mWebView.getSettings().setAllowFileAccess(true);
mWebView.getSettings().setAllowContentAccess(true);
mWebView.getSettings().setAllowFileAccessFromFileURLs(true);
mWebView.getSettings().setAllowUniversalAccessFromFileURLs(true);
//load file
mWebView.loadUrl("file:///android_asset/www/index.html");
从XMLHttpRequest无法从模拟器上的android资源文件夹加载文件