2015-06-23 28 views
0

您好,我正在使用Filepicker Plugin从我的iOS cordova application中获取图库中的图像和视频。使用cordova在iOS中使用库播放视频

当我们从图库中选择图片或视频时,我们会从插件获取图片和视频的临时路径。 我在图像标签中显示图像,但视频未播放。看起来临时路径不会播放。 是否有任何解决方案获得actual path for play the video或有没有plugin for iOS to convert temporary path to actual path

请帮忙..

回答

2

我也有同样的问题。您拥有的临时路径是应用程序缓存文件夹的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) { } 

干杯。

+0

LOL ...它的工作.. :-)谢谢! –