2015-08-24 84 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

相關問題