如何在angularjs中播放视频?

时间:2022-08-27 00:10:21

hi i have a list of items in that both video url and image url i am displaying that as below

嗨,我有一个项目列表,在视频网址和图像网址我显示如下

HTML code

<div ng-app="myApp" ng-controller="myCtrl">
<div class="news_image" ng-repeat="image in items.media">
    <img ng-src="{{image.src}}" ng-if="image.type === 'img'" />
    <video ng-if="image.type === 'video'" width="320" height="240" controls>
      <source ng-src="{{image.src}}" type="video/mp4">
    </video>
</div>

and angular js code

和角度js代码

angular.module('myApp', [])
.controller('myCtrl', function ($scope) {
$scope.items = {
    "media": [{
        "type": "img",
        "src": "http://images/2015/May/161887.jpg"
    }, {
        "type": "video",
        "src": "http:/video/2015/May/161887.mp4",
    }]
};

});

The problem is the images are working properly but the video is not working. how can i fix this?

问题是图像工作正常但视频无法正常工作。我怎样才能解决这个问题?

1 个解决方案

#1


1  

There is a typo in your code. Video src is wrong.

您的代码中存在拼写错误。视频src是错误的。

angular.module('myApp', [])
.controller('myCtrl', function ($scope) {
$scope.items = {
    "media": [{
        "type": "img",
        "src": "http://images/2015/May/161887.jpg"
    }, {
        "type": "video",
        "src": "http://video/2015/May/161887.mp4",
    }]
};
});

#1


1  

There is a typo in your code. Video src is wrong.

您的代码中存在拼写错误。视频src是错误的。

angular.module('myApp', [])
.controller('myCtrl', function ($scope) {
$scope.items = {
    "media": [{
        "type": "img",
        "src": "http://images/2015/May/161887.jpg"
    }, {
        "type": "video",
        "src": "http://video/2015/May/161887.mp4",
    }]
};
});