2015-08-24 55 views
0

我想要使用包含Twitch WebPlayer的webView。但是,当我启动我的应用程序时,播放器不希望启动(抽搐定义如果我们需要使用Flash或HTML5播放器)。我的应用程序启动HTML5播放器,但她正在加载,加载,加载...她无法启动流。交叉来源请求仅支持http,数据,https

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"); 

(如果你想尝试,通道为例:OgamingLOL)

如果我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) 

我已经尝试获取的结果,但我没看到它......

你能帮助我PLS =)

谢谢你,有一个美好的一天: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/(这并不能帮助我)

+0

我升级我的帖子 – Argardor

回答

1

试试这个:

// 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 cannot load file from android asset folder on emulator

+0

您从这里HTTPS复制的答案:/ /stackoverflow.com/questions/23955050/xmlhttprequest-cannot-load-file-from-android-asset-folder-on-emulator – Steven

相关问题