2017-08-15 41 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