gpt4 book ai didi

ios - 使用 cordova 在 iOS 中播放图库中的视频

转载 作者:行者123 更新时间:2023-11-28 21:43:58 25 4
gpt4 key购买 nike

您好,我正在使用 Filepicker Plugin用于从我的 iOS cordova 应用程序 中的图库获取图像和视频。

当我们从图库中选择图像或视频时,我正在从插件中获取图像和视频的临时路径。我在图片标签中显示了图片,但视频没有播放。看来临时路径will-not played。是否有任何解决方案来获取播放视频的实际路径,或者是否有任何iOS 插件将临时路径转换为实际路径

请帮忙..

最佳答案

我也遇到了同样的问题。您拥有的临时路径是应用程序缓存文件夹的 url。我通过保存本地选择的文件并随后使用生成的路径在我的应用程序上解决了这个问题。

我使用下面的代码来解决这个问题。

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, failrequestFileSystem);

function gotFS(fileSystem) {
fileSystem.root.getDirectory("vids", {create: true}, gotDir);
}

function gotDir(dirEntry) {
dirEntry.getFile("video.MOV", {create: true, exclusive: false}, gotFile);
}

function gotFile(fileEntry) {
var localPath = fileEntry.fullPath;
var localUrl = fileEntry.toURL();

var fileTransfer = new FileTransfer();
var uri = encodeURI(<temp path that u have>);
fileTransfer.download(
uri,
localUrl,
function(entry) {
uralToUse = entry.nativeURL; // use this url to play video
var videoNode = document.querySelector('video');
videoNode.src = entry.toNativeURL();
},
function(error) { }
);
}

function failrequestFileSystem(error) { }

干杯。

关于ios - 使用 cordova 在 iOS 中播放图库中的视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31008984/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com