视频js无法按预期使用角度和FF

时间:2015-03-06 05:14:56

标签: angularjs html5 firefox video

我需要创建包含自动播放视频的网站,并依赖于用户选择的个人资料。所以在angular我创建模板popupVideo:

<video id="example_video_1" class="video-js vjs-default-skin"
       controls autoplay preload="auto" height="100%" width="100%">
  <source ng-repeat="vidObj in fullScreenVideoUrl" src="{{vidObj.url}}" type="{{vidObj.type}}"/>
  <p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>
</video>

然后在控制器中我有代码:

function showPopupVideo() {
        $scope.fullScreenVideoUrl = [];
        var webm = {};
        webm.url = $scope.currentProfile.video_full + ".webm";
        webm.type = "video/webm";
        $scope.fullScreenVideoUrl.push(webm);
        var mp4 = {};
        mp4.url = $scope.currentProfile.video_full + ".mp4";
        mp4.type = "video/mp4";
        $scope.fullScreenVideoUrl.push(mp4);
        var ogg = {};
        ogg.url = $scope.currentProfile.video_full + ".ogv";
        ogg.type = "video/ogg";
        $scope.fullScreenVideoUrl.push(ogg);
        ngDialog.open({
          template: 'scripts/contents/template/popupVideo.html',
          className: 'popup-fullscreen',
          scope: $scope
        });
      }

所以Chrome和IE中的所有工作都很好,窗口打开视频开始和播放。 但是在FF出错的时候,当窗口第一次打开时,它开始下载(根据网络监视器)但没有自动播放,也在控制台中我可以看到:

Specified "type" attribute of "{{vidObj.type}}" is not supported. Load of media resource {{vidObj.url}} failed. localhost:3000
All candidate resources failed to load. Media load paused. localhost:3000
All candidate resources failed to load. Media load paused.

然而!如果我按播放它开始播放视频!

然后,如果我关闭此窗口并再次打开,它会在控制台中显示不支持的相同文本,但现在它开始播放视频,同时在其上显示“没有支持格式和MIME类型的视频”这怎么可能???它无法找到并同时播放它......

1 个答案:

答案 0 :(得分:0)

可能为时已晚,但您需要做的是使用ng-src =“{{vidObj.url}}”而不是src =“{{vidObj.url}}”