2017-08-15 57 views
0

我成功地捕捉視頻流與下面的代碼:科爾多瓦視頻採集 - 如何獲得blob數據?

 navigator.device.capture.captureVideo(

      //...after recorded vid 
      function(mediaFiles) { 
       var i, path, len; 
       for (i = 0, len = mediaFiles.length; i < len; i += 1) { 
        path = mediaFiles[i].fullPath; 
        app.f7.alert(path); 
       } 
      }, 

      //...couldn't get camera 
      function() { app.f7.alert('Sorry - your recording device could not be accessed', 'Error'); }, 

      //...config 
      {limit:2} 
     ); 

我想不通的是如何抓住保存的視頻的BLOB數據。我有文件路徑到本地保存的文件,但我需要將數據保存到遠程服務器,所以我需要它的數據。

成功回調傳遞一個MediaFile對象封裝捕獲的視頻,但the docs don't discuss獲取其原始數據的任何手段。任何人都知道這可以實現嗎?

回答

1

因爲媒體文件會給你有關文件的信息本身,如

name: The name of the file, without path information. (DOMString) 
fullPath: The full path of the file, including the name. (DOMString) 
type: The file's mime type (DOMString) 
lastModifiedDate: The date and time when the file was last modified. (Date) 
size: The size of the file, in bytes. (Number) 

MediaFileData就可以訪問

codecs: The actual format of the audio and video content. (DOMString) 
bitrate: The average bitrate of the content. The value is zero for images. (Number) 
height: The height of the image or video in pixels. The value is zero for audio clips. (Number) 
width: The width of the image or video in pixels. The value is zero for audio clips. (Number) 
duration: The length of the video or sound clip in seconds. The value is zero for images. (Number) 

,而不是視頻的內容。如果您想閱讀它的內容,請使用MediaFile.fullPath加載它。

要加載視頻,請檢查this post這可能會使您走上正軌。

+0

謝謝。 「使用MediaFile.fullPath加載它」 - 這正是我所要求的。我有完整的路徑,但我不知道如何讀取路徑指向blob文件的內容。 – Utkanos

+0

請參閱https://stackoverflow.com/questions/37327992/cordova-file-plugin-to-load-video-source-from-ios-cache – Eric

+0

謝謝。我會調查一下 - 雖然這個問題沒有被接受的答案,並且評論表明OP從未解決過這個問題。 – Utkanos