IOS Cordova/Phonegap 离线视频源标签不起作用

IOS Cordova/Phonegap offline video source tag not working

本文关键字:标签 不起作用 视频 离线 Cordova Phonegap IOS      更新时间:2023-09-26

在IOS上 当我使用cordova文件传输插件下载一些视频时,它无法播放(绝对网址如:file:///var/mobile../videos/1.mp4),但是当我将视频包装到应用程序中时,它可以工作(相对网址如:"videos/1.mp4")。

在安卓上两者都有效。

脚本:

var fileTransfer = new FileTransfer();
var uri = encodeURI("http://some.server.com/download.php");
fileTransfer.download(
    uri,
    fileURL,
    function(entry) {
        generateMarkup(entry);
    },
    function(error) {
        handleError(error);
    },
);

generateMarkup() 函数按照 w3c 的建议创建标记 http://www.w3schools.com/html/html5_video.asp

<video width="320" height="240" controls>
  <source src="file:///var/mobile/.../movie.mp4" type="video/mp4">
  <source src="file:///var/mobile/.../movie.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>

我已经编写了帮助程序来打印出存储在应用程序沙箱中的所有文件,因此文件在那里,路径正确,但它无法播放。

经过两天的挖掘,找到了这个页面: https://issues.apache.org/jira/browse/CB-6051

是什么帮助弄清楚iOS 7.x?无法处理源元素中的本地绝对路径。(我的:iOS 7.0.4)它只是给出了一个与一条线交叉的游戏图标。

这是行不通的:

<video width="320" height="240" controls>
  <source src="file:///var/mobile/.../movie.mp4" type="video/mp4">
  <source src="file:///var/mobile/.../movie.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>

然而这个终于起作用了...

<video width="320" height="240" src="file:///var/mobile/.../movie.mp4" controls>
  Your browser does not support the video tag.
</video>

希望它对某人有所帮助。

相关文章: