我正在加载一个WebView
的网页,并在WebView
中加载一个iframe,其中有一个加载游戏的画布。我不知道为什么,但游戏并没有加载。在控制台中,我可以看到它将http请求输出到运行游戏所需的文件,但一旦完成,我就会留下一个黑色的空屏幕。如果我在模拟器Web浏览器中打开相同的URL,则游戏会加载并且可以播放。我该怎么做才能让它在应用程序中播放?
public class Play extends Activity {
private WebView webView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
String url = intent.getStringExtra("gameUrl");
setContentView(R.layout.activity_play);
// Setup the WebView
webView = (WebView) findViewById(R.id.gameWebView);
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
webView.setWebChromeClient(new WebChromeClient());
webView.setInitialScale(1);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setLoadsImagesAutomatically(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
System.out.println(url);
// Load a default URL into the webview
webView.loadUrl(url);
}
}
以下是页面加载时的输出:
--------- beginning of system
09-13 19:54:34.894 5435-5435/com.gamesmart.gamesmart W/art: Attempt to remove non-JNI local reference, dumping thread
09-13 19:54:34.895 5435-5435/com.gamesmart.gamesmart W/AwContents: onDetachedFromWindow called when already detached. Ignoring
09-13 19:54:34.897 5435-5435/com.gamesmart.gamesmart I/System.out: http://dev.gamesmart.com/mobile/play/gamesmart/tower-of-babel
09-13 19:54:35.961 5435-5476/com.gamesmart.gamesmart E/Surface: getSlotFromBufferLocked: unknown buffer: 0xae473ed0
09-13 19:54:36.170 5435-5435/com.gamesmart.gamesmart W/BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 5435
09-13 19:54:36.807 5435-5435/com.gamesmart.gamesmart I/chromium: [INFO:CONSOLE(29)] "mjs_game_id:", source: http://mjs.gamesmart.com/serve?portal_id=5269991175749632&game_id=5656313283477504&branding_id=4751999195152384&ad_id=6127931696873472&portal_localization_id=4958697046409216 (29)
09-13 19:54:36.807 5435-5435/com.gamesmart.gamesmart I/chromium: [INFO:CONSOLE(30)] "mjs_portal_id:", source: http://mjs.gamesmart.com/serve?portal_id=5269991175749632&game_id=5656313283477504&branding_id=4751999195152384&ad_id=6127931696873472&portal_localization_id=4958697046409216 (30)
09-13 19:54:36.808 5435-5435/com.gamesmart.gamesmart I/chromium: [INFO:CONSOLE(31)] "mjs_branding_id:", source: http://mjs.gamesmart.com/serve?portal_id=5269991175749632&game_id=5656313283477504&branding_id=4751999195152384&ad_id=6127931696873472&portal_localization_id=4958697046409216 (31)
09-13 19:54:36.808 5435-5435/com.gamesmart.gamesmart I/chromium: [INFO:CONSOLE(32)] "mjs_ad_id:", source: http://mjs.gamesmart.com/serve?portal_id=5269991175749632&game_id=5656313283477504&branding_id=4751999195152384&ad_id=6127931696873472&portal_localization_id=4958697046409216 (32)
09-13 19:54:36.898 5435-5435/com.gamesmart.gamesmart I/chromium: [INFO:CONSOLE(449)] "no localstorage found", source: http://mjs.gamesmart.com/serve?portal_id=5269991175749632&game_id=5656313283477504&branding_id=4751999195152384&ad_id=6127931696873472&portal_localization_id=4958697046409216 (449)
09-13 19:54:36.902 5435-5435/com.gamesmart.gamesmart I/chromium: [INFO:CONSOLE(573)] "prepare Change Username form ...", source: http://mjs.gamesmart.com/serve?portal_id=5269991175749632&game_id=5656313283477504&branding_id=4751999195152384&ad_id=6127931696873472&portal_localization_id=4958697046409216 (573)
09-13 19:54:36.905 5435-5435/com.gamesmart.gamesmart I/chromium: [INFO:CONSOLE(608)] "Uncaught TypeError: Cannot read property 'getItem' of null", source: http://mjs.gamesmart.com/serve?portal_id=5269991175749632&game_id=5656313283477504&branding_id=4751999195152384&ad_id=6127931696873472&portal_localization_id=4958697046409216 (608)
09-13 19:54:36.928 5435-5435/com.gamesmart.gamesmart I/chromium: [INFO:CONSOLE(1105)] "serving universal version ...", source: http://mjs.gamesmart.com/serve?portal_id=5269991175749632&game_id=5656313283477504&branding_id=4751999195152384&ad_id=6127931696873472&portal_localization_id=4958697046409216 (1105)
09-13 19:54:36.957 5435-5435/com.gamesmart.gamesmart I/chromium: [INFO:CONSOLE(587)] "AdInGamePreroll disabled in CMS ...", source: http://mjs.gamesmart.com/serve?portal_id=5269991175749632&game_id=5656313283477504&branding_id=4751999195152384&ad_id=6127931696873472&portal_localization_id=4958697046409216 (587)
09-13 19:54:36.961 5435-5435/com.gamesmart.gamesmart I/chromium: [INFO:CONSOLE(636)] "changing orientation ...", source: http://mjs.gamesmart.com/serve?portal_id=5269991175749632&game_id=5656313283477504&branding_id=4751999195152384&ad_id=6127931696873472&portal_localization_id=4958697046409216 (636)
09-13 19:54:37.085 5435-5458/com.gamesmart.gamesmart E/WVMExtractor: Failed to open libwvm.so: dlopen failed: library "libwvm.so" not found
09-13 19:54:37.098 5435-5458/com.gamesmart.gamesmart D/WebAudioMediaCodec: Initial: Tracks: 1 Format: {csd-1=java.nio.ByteArrayBuffer[position=0,limit=3771,capacity=3771], mime=audio/vorbis, durationUs=838662, csd-0=java.nio.ByteArrayBuffer[position=0,limit=30,capacity=30], channel-count=1, sample-rate=44100}
09-13 19:54:37.108 5435-5653/com.gamesmart.gamesmart I/OMXClient: Using client-side OMX mux.
09-13 19:54:37.177 5435-5458/com.gamesmart.gamesmart D/WebAudioMediaCodec: output format changed to {channel-count=1, what=1869968451, mime=audio/raw, sample-rate=44100}
09-13 19:54:37.177 5435-5458/com.gamesmart.gamesmart D/WebAudioMediaCodec: Final: Rate: 44100 Channels: 1 Mime: audio/vorbis Duration: 838662 microsec
09-13 19:54:37.315 5435-5457/com.gamesmart.gamesmart D/WebAudioMediaCodec: Initial: Tracks: 1 Format: {csd-1=java.nio.ByteArrayBuffer[position=0,limit=3365,capacity=3365], mime=audio/vorbis, durationUs=862040, csd-0=java.nio.ByteArrayBuffer[position=0,limit=30,capacity=30], channel-count=1, sample-rate=44100}
09-13 19:54:37.319 5435-5660/com.gamesmart.gamesmart I/OMXClient: Using client-side OMX mux.
09-13 19:54:37.352 5435-5470/com.gamesmart.gamesmart D/MediaResourceGetter: no ethernet/wifi connection detected
09-13 19:54:37.352 5435-5470/com.gamesmart.gamesmart W/MediaResourceGetter: non-file URI can't be read due to unsuitable network conditions
09-13 19:54:37.352 5435-5470/com.gamesmart.gamesmart E/MediaResourceGetter: Unable to configure metadata extractor
09-13 19:54:37.365 5435-5457/com.gamesmart.gamesmart D/WebAudioMediaCodec: output format changed to {channel-count=1, what=1869968451, mime=audio/raw, sample-rate=44100}
09-13 19:54:37.365 5435-5457/com.gamesmart.gamesmart D/WebAudioMediaCodec: Final: Rate: 44100 Channels: 1 Mime: audio/vorbis Duration: 862040 microsec
09-13 19:54:37.423 5435-5458/com.gamesmart.gamesmart D/WebAudioMediaCodec: Initial: Tracks: 1 Format: {csd-1=java.nio.ByteArrayBuffer[position=0,limit=4225,capacity=4225], mime=audio/vorbis, durationUs=862040, csd-0=java.nio.ByteArrayBuffer[position=0,limit=30,capacity=30], channel-count=2, sample-rate=44100}
09-13 19:54:37.428 5435-5663/com.gamesmart.gamesmart I/OMXClient: Using client-side OMX mux.
09-13 19:54:37.450 5435-5458/com.gamesmart.gamesmart D/WebAudioMediaCodec: output format changed to {channel-count=2, what=1869968451, mime=audio/raw, sample-rate=44100}
09-13 19:54:37.453 5435-5458/com.gamesmart.gamesmart D/WebAudioMediaCodec: Final: Rate: 44100 Channels: 2 Mime: audio/vorbis Duration: 862040 microsec
09-13 19:54:37.494 5435-5457/com.gamesmart.gamesmart D/WebAudioMediaCodec: Initial: Tracks: 1 Format: {csd-1=java.nio.ByteArrayBuffer[position=0,limit=3365,capacity=3365], mime=audio/vorbis, durationUs=501904, csd-0=java.nio.ByteArrayBuffer[position=0,limit=30,capacity=30], channel-count=1, sample-rate=44100}
09-13 19:54:37.499 5435-5666/com.gamesmart.gamesmart I/OMXClient: Using client-side OMX mux.
09-13 19:54:37.514 5435-5457/com.gamesmart.gamesmart D/WebAudioMediaCodec: output format changed to {channel-count=1, what=1869968451, mime=audio/raw, sample-rate=44100}
09-13 19:54:37.514 5435-5457/com.gamesmart.gamesmart D/WebAudioMediaCodec: Final: Rate: 44100 Channels: 1 Mime: audio/vorbis Duration: 501904 microsec
09-13 19:54:37.530 5435-5458/com.gamesmart.gamesmart D/WebAudioMediaCodec: Initial: Tracks: 1 Format: {csd-1=java.nio.ByteArrayBuffer[position=0,limit=4225,capacity=4225], mime=audio/vorbis, durationUs=626938, csd-0=java.nio.ByteArrayBuffer[position=0,limit=30,capacity=30], channel-count=2, sample-rate=44100}
09-13 19:54:37.533 5435-5669/com.gamesmart.gamesmart I/OMXClient: Using client-side OMX mux.
09-13 19:54:37.542 5435-5458/com.gamesmart.gamesmart D/WebAudioMediaCodec: output format changed to {channel-count=2, what=1869968451, mime=audio/raw, sample-rate=44100}
09-13 19:54:37.543 5435-5458/com.gamesmart.gamesmart D/WebAudioMediaCodec: Final: Rate: 44100 Channels: 2 Mime: audio/vorbis Duration: 626938 microsec
09-13 19:55:07.828 5435-5435/com.gamesmart.gamesmart I/chromium: [INFO:CONSOLE(292)] "MarketJS API Log Time Spent: ", source: http://mjs.gamesmart.com/serve?portal_id=5269991175749632&game_id=5656313283477504&branding_id=4751999195152384&ad_id=6127931696873472&portal_localization_id=4958697046409216 (292)
09-13 19:55:07.963 5435-5435/com.gamesmart.gamesmart I/chromium: [INFO:CONSOLE(300)] "200", source: http://mjs.gamesmart.com/serve?portal_id=5269991175749632&game_id=5656313283477504&branding_id=4751999195152384&ad_id=6127931696873472&portal_localization_id=4958697046409216 (300)