Android webview html5 视频自动播放在 android 4.0.3 上不起作用 [英] Android webview html5 video autoplay not working on android 4.0.3

查看:22
本文介绍了Android webview html5 视频自动播放在 android 4.0.3 上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个应用程序,用户可以在其中设置网页上的视频:- 他们可以指定一个 Youtube URL或者- 他们可以上传视频

I have developed an application where the user can set videos on a web page: - They can specify a Youtube URL OR - They can upload a video

根据用户选择的选项,我呈现这样的视频页面:如果视频来自 youtube:

Depending on which option the user chooses i render a video page like this : If a video is from youtube:

<iframe type="text/html" width="640" height="385" src="http://www.youtube.com/embed/YOUTUBEID?autoplay=1&loop=1&autohide=1&fs=0"  frameborder="0"></iframe>

如果视频正在上传:

<video id="video" style="cursor: pointer;" width="640" height="480"  autoplay controls loop>
  <source src="../video/Tareas_Diarias_Resumen.mp4" type="video/mp4" />
</video>

好的.所有这些都可以在 Google Chrome 上完美运行,但事实是该视频将在 16 台三星 GT-P5100 Android 4.03 平板电脑上观看.

OK. All this works perfect on Google Chrome, but the fact is that the video is going to be watched on 16 Samsung GT-P5100 Android 4.03 Tablets.

我们创建了一个嵌入 webView 的 Android 应用程序:

We created an Android application which embeds an webView like that:

WebView engine = (WebView) findViewById(R.id.web_engine);
engine.setWebChromeClient(new WebChromeClient());
engine.getSettings().setPluginsEnabled(true);
engine.getSettings().setPluginState(PluginState.ON);
engine.getSettings().setJavaScriptEnabled(true);
engine.getSettings().setAllowFileAccess(true);
engine.loadUrl(miUrl);

这里我有两个问题:1-Youtube 视频.它工作正常,我可以看到视频但没有自动播放,我们希望它可以自动播放.有什么解决办法吗?2- 上传的视频不起作用,我可以看到播放器但没有视频.

And here I have two issues: 1- Youtube video. It works ok, I can see the video but with no autoplay, and we want it to work with autoplay. Any solution? 2- The uploaded video does not work, I can see the player but no video.

视频转手刹,选择iphone &ipod-touch 预设和网页优化"选项.

The video was converted with handbrake, choosing iphone & ipod-touch preset and "Web Optimized" option.

任何帮助或线索?提前致谢

Any help or clue? Thanks in advance

推荐答案

[已升级为按请求回答]

[upgraded to answer per request]

大多数移动平台(Android、iOS)上的自动播放被阻止以避免糟糕的用户体验 - 视频应仅在用户操作后播放.您通常可以通过在另一个事件(例如 onloaded 事件)上触发 play() 来解决它

Autoplay on most mobile platforms (Android, iOS) gets blocked to avoid poor user experiences - video should only play following a user action. You can usually work around it by triggering the play() on another event (eg the onloaded event)

这篇关于Android webview html5 视频自动播放在 android 4.0.3 上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆