本文介绍了使用html视频标签从www文件夹播放视频(在android上)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码显示视频

I'm using the following code to display a video

<video id="v1" class="no-fastclick" controls>
    <source class="no-fastclick" src="img/home.mp4" type="video/mp4">
</video>

实际上几乎一切正常。视频是可播放的,但我只有声音。但是,当全屏显示时,我也会看到视频。所以一切似乎都是正确的 - 除非它没有出现在全屏幕上。

Actually "nearly" everything works. The Video is playable but I only have sound. However, when making it fullscreen I also see the video. So everything seems to be right - except that it doesn't show up when not being in full screen.

我找不到强制点击或制作全屏的方法它可以在小版本中播放。

I cannot found a method to force the fullscreen on click or make it playable in small version.

推荐答案

更新

在下面的评论中与OP讨论后,我构建了一个测试应用程序并将其上传到OP。

After discussing with the OP in the comments below, I built a test app and uploaded it for the OP.

我已确认视频适用于实际设备。在模拟器上尝试了相同的应用程序后,我能够重现该问题。这似乎是一个模拟器问题,而不是Cordova或实际设备的问题。

I have confirmed the video works on an actual device. Having tried the same app on the emulator I was able to reproduce the issue. It would seem that this is an emulator issue and not an issue with Cordova or actual devices.

编辑

看来你不是唯一有这个问题的人。有一个插件可以让视频标签在这里正常工作:

It seems you are not the only one having this issue. There is a plugin that should enable video tags to work properly here:

安装:

cordova plugin add https://github.com/jaeger25/Html5Video.git

样本用法:

<video id="myvideo" loop></video>

希望这会有效!

原始

您可能需要添加像这样的webkit-playsinline属性例如:

You may need to add the webkit-playsinline attribute like this example:

<video webkit-playsinline>
    <source src="mySource.mp4" type="video/mp4">
</video>

此外,您可能需要将此添加到您的config.xml

Also you may need to add this to your config.xml

<preference name="AllowInlineMediaPlayback" value="true"/>

这篇关于使用html视频标签从www文件夹播放视频(在android上)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 22:45