I'm having a problem trying to set a source to a video in AngularJS.
Here's the HTML code of the view:
<div class="row">
<div class="col-lg-10 col-lg-offset-1">
<video width="100%" controls>
<source ng-src="{{levelContent.levelVideo}}" type="video/mp4">
<!--<source ng-src="Content\img\cortes.mp4" type="video/mp4">-->
Your browser does not support HTML5 video.
</video>
</div>
</div>
Here's the code of the controller of that view:
(function () {
'use strict';
angular
.module('iziCooker')
.controller('LevelController', LevelController);
LevelController.$inject = ['$scope', 'LevelContentService', '$routeParams', 'LevelService', '$sce' ,'$location'];
function LevelController($scope, LevelContentService, $routeParams, LevelService, $sce ,$location) {
$scope.levelId = -1;
$scope.levelContent = [];
function GetLevelContent() {
LevelContentService.SetLevelId($routeParams.levelId);
$scope.levelId = LevelContentService.GetLevelId();
LevelService.GetLevelContent($scope.levelId).then(function (data) {
$scope.levelContent = data;
LevelContentService.SetLevelName = data.name + " - " + data.description;
$scope.levelContent.levelVideo = $sce.trustAsResourceUrl(data.levelVideo);
});
}
GetLevelContent();
console.log("Level Controller Loaded!");
}
})();
I'm testing my application on IE and Chrome, with the first one it works properly but no with the second one which I mostly use.
On IE:
On Chrome:
I tested the video individually on Chrome and it works fine. Also I tried with the hardcoded src as you can see above and it works too. I thought it could be something with the $sce but seems it doesn't.