我正在尝试使用角度缩略图(https://github.com/aztech-digital/angular-thumbnails)从本地视频文件而不是视频网址生成缩略图,这是我到目前为止所做的,它仅适用于某些视频:https://plnkr.co/edit/j7LR7FU0itRmPmLJWgwT?p=preview < / p>
var app = angular.module('plunker', ['angular-thumbnails']);
app.controller('MainCtrl', function($scope) {
$scope.$watch('myFile', function(newVal, oldVal) {
var reader = new FileReader();
reader.addEventListener('load', function() {
$scope.myVideoData = reader.result;
console.log('myVideoData', $scope.myVideoData);
}, false);
if (newVal) {
reader.readAsDataURL(newVal);
}
});
});
app.directive('fileModel', function() {
return {
restrict: 'A',
scope: {
fileModel: '='
},
link: function(scope, element, attrs) {
element.bind('change', function(e) {
scope.$apply(function() {
scope.fileModel = e.target.files[0];
});
});
}
};
});