Uploading video to Firebase uing ngCordova ($cordovaCapture) in ionic framework

余生长醉 提交于 2019-12-04 17:59:48
David East

It's hard to tell without running the app myself, but I do see an issue with your record function.

Don't initialize the $firebaseArray inside of the record function, do it when the controller initializes:

.controller("HomeCtrl", function($scope, $firebaseArray, $cordovaCamera, $location, $cordovaCapture){
  var fb = new Firebase("https://myURL.firebaseio.com/videos");
  $scope.videos = $firebaseArray(fb);
  $scope.record = function record() {
     // ... your record code here 
  };
})

The $firebaseArray is in sync with the server, so it only needs to be created once.

As for your display issue...

You need to change the src attribute in <source> to ng-src, and use curlys {{ }} to interpolate:

<video controls>
    <source ng-src="{{video.videosrc}}" type="video/mp4">
</video>

For more information on HTML attrs vs directives, see this answer.

.controller("HomeCtrl", function($scope, $firebaseArray, $location, $cordovaCapture){
var fb = new Firebase("https://myURL.firebaseio.com/videos");
$scope.videos;
$scope.record = function(){
    fb = new Firebase("https://myURL.firebaseio.com/videos");
  $scope.videos = $firebaseArray(fb);
  var options = { limit: 1, duration: 15 };
  $cordovaCapture.captureVideo(options).then(
      function(videoData) {
          var i, path, len;
          var pathtogo;
          var pathtogostring;
          for (i = 0, len = videoData.length; i < len; i += 1) {
              path = videoData[i].fullPath;
              pathtogo = path.toString();


              obj = {
                    videosrc: pathtogo 
              }
              $scope.videos.$add(obj);
            }
      },
      function(err) {
      }
  );
}//end record
 })//end controlle
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!