我无法在Android网页视图上播放视频.
我已将HTML和视频文件保存在我的assets文件夹中.
每当我加载HTML文件时,它都会给我错误
05-01 12:31:16.092: E/MediaResourceGetter(17241): Unable to read file: file:///androID_asset/MediaBook2%20(2)/2B952499A0E681.mp4
每当我按下播放按钮时,我都会收到以下错误
05-01 12:31:23.680: E/chromium(17241): [ERROR:webmediaplayer_androID.cc(328)] Not implemented reached in virtual voID content::WebMediaPlayerAndroID::setRate(double)05-01 12:31:23.710: E/MediaPlayer(17241): error (1,-2147483648)05-01 12:31:23.710: E/MediaPlayer(17241): Error (1,-2147483648)
能够加载任何远程视频并运行,但问题是我从资源文件夹加载本地视频
用于加载文件和设置Web视图的代码
@OverrIDeprotected voID onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); // Remove Title bar requestwindowFeature(Window.FEATURE_NO_Title); setContentVIEw(R.layout.activity_webvIEw); mContentVIEw = (linearLayout) findVIEwByID(R.ID.linearlayout); // Keep the webvIEw setup ready setupWebVIEw();}public voID setupWebVIEw(){ webVIEw = (WebVIEw) findVIEwByID(R.ID.webVIEw); // progressbar = (Progressbar) findVIEwByID(R.ID.progressbarForWebVIEw); WebSettings webVIEwSettings = webVIEw.getSettings(); webVIEwSettings.setJavaScriptEnabled(true); webVIEwSettings.setJavaScriptCanopenwindowsautomatically(true); webVIEwSettings.setPluginState(PluginState.ON); webVIEw.getSettings().setAllowfileAccess(true); webVIEw.setSoundEffectsEnabled(true); webVIEw.setWebVIEwClIEnt(new SLCWebVIEwClIEnt()); webVIEw.setWebChromeClIEnt(new WebChromeClIEnt()); loadContentsInWebVIEw();}public voID loadContentsInWebVIEw() { String localURL = "file:///androID_asset/MediaBook2 (2)/SampleForVIDeo.HTML"; logger.deBUG("WebVIEw URL: {}",localURL); try { webVIEw.loadUrl(localURL); } catch (Exception e) { e.printstacktrace(); logger.error("Error while loading url",e); } } private class SLCWebVIEwClIEnt extends WebVIEwClIEnt{ @OverrIDe public boolean shouldOverrIDeUrlLoading(WebVIEw vIEw,String url) { vIEw.setWebChromeClIEnt(new WebChromeClIEnt() { private VIEw mCustomVIEw; @OverrIDe public voID onShowCustomVIEw(VIEw vIEw,WebChromeClIEnt.CustomVIEwCallback callback) { // if a vIEw already exists then immediately terminate the new one if (mCustomVIEw != null) { callback.onCustomVIEwHIDden(); return; } // Add the custom vIEw to its container. mCustomVIEwContainer.addVIEw(vIEw,COVER_SCREEN_GraviTY_CENTER); mCustomVIEw = vIEw; mCustomVIEwCallback = callback; // hIDe main browser vIEw mContentVIEw.setVisibility(VIEw.GONE); // Finally show the custom vIEw container. mCustomVIEwContainer.setVisibility(VIEw.VISIBLE); mCustomVIEwContainer.bringToFront(); } }); webVIEw.loadUrl(url); return true; }
Sample for VIDeo.HTML代码
布局文件的代码
干杯,
Saurav最佳答案file:/// androID_asset协议是特定于WebVIEw的东西.也就是说:其他系统组件无法读取这些URL.
MediaResourceGetter不使用WebVIEw的网络堆栈,因此不“理解”file:/// androID_asset协议.
在你提到的另一个问题中,你使用的是本地http服务器 – 尝试从中提供.mp4.
总结 以上是内存溢出为你收集整理的android – 无法在Web View中播放视频全部内容,希望文章能够帮你解决android – 无法在Web View中播放视频所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)