【问题标题】:download success but video don't shows in IOS cordova下载成功,但视频在 IOS cordova 中不显示
【发布时间】:2017-10-21 17:38:32
【问题描述】:

在使用cordova plugin file transfer时,下载文件成功,但没有显示在任何地方,代码添加如下:

var onGetDirectorySuccess = function(fileEntry) {
    downloadpostnow(fileEntry, 'http://50.63.14.130/Images/OrderProof/Plugd7a09191-7cdd-4f21-babd-041e3f914ebb.MOV');
}

var onGetDirectoryFail = function(error) {
    showError("There is an error while processing your download.",0);
    return false;
}

var onRequestFileSystemSuccess = function(fileSystem) {
    var entry=fileSystem.root;
    entry.getDirectory("plug", {create: true, exclusive: false}, onGetDirectorySuccess, onGetDirectoryFail);
}

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onRequestFileSystemSuccess, null);

function downloadpostnow(fileEntry, uri){
var fileTransfer = new FileTransfer();
var fileURL = fileEntry.toURL();
var uri = encodeURI(uri);
var uriname = uri.split("/");
uriname = uriname[uriname.length-1];
fileTransfer.download(
    uri,
    fileURL+uriname,
    function (entry) {
        alert(JSON.stringify(entry));
        //showError("Download Completed.",1);
        fileTransfer.abort();
    },
    function (error) {
        fileTransfer.abort();
        //showError("There is an error while downloading your post.",0);
        return false;
    },
    true,
    {/**/}
);
}

使用此功能,文件下载完成,IOS不显示

【问题讨论】:

  • 存储在文档目录中。可以分享下载视频的路径吗?你可以使用 fileURL 。
  • file://var/mobile/Containers/Data/Application/some_id/Documents/plug/Plugd7a09191-7cdd-4f21-babd-041e3f914ebb.MOV
  • 您能说明一下您想在 iOS 的哪个位置观看视频吗?

标签: jquery ios cordova


【解决方案1】:

如果你想显示下载的视频。

这是我的工作:

  1. (一次!)确保所有隐藏文件在您的 Mac 上可见: 在终端窗口运行: 默认写入 com.apple.Finder AppleShowAllFiles YES

  2. 在 Xcode 中,打开 Organizer -> Devices,找到您的 iPhone,然后在 Applications 文件夹中找到您的应用程序。

  3. 在底部单击下载并将应用程序下载到您的桌面(任何位置)

  4. 打开 Finder,导航到下载的文件,右键单击它并选择显示包内容。该视图将更改为标准取景器视图,并在该应用程序中打开文件。 (跟随url文件路径)

  5. 转到 Documents 文件夹,找到您的 *.MOV 文件,右键单击它并选择打开方式 -> 其他。

【讨论】:

  • 感谢重播,但我的意思是视频未显示在设备中,例如:在照片中
  • 您需要将视频写入图库。
  • 尝试在 google 中搜索 UISaveVideoAtPathToSavedPhotosAlbum。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-01-20
  • 2021-06-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多