2015-06-23 29 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 ...它的工作.. :-)謝謝! –