我需要在一个页面上显示多个videogular个视频,每个视频都有一个按钮,可以启动视频。我需要将每个视频的范围放入指令中,如here所述。
虽然我无法访问视频网的API。我很确定问题是onPlayerReady函数。 API上有很多documentation,但我没有设法让它工作。
指令:
.directive("topmVideogularDirective", function () {
return {
restrict: 'E',
scope: {
data: "=",
config: "="
},
template: '<videogular vg-plays-inline="true" vg-player-ready="onPlayerReady"><vg-media vg-src="data" vg-native-controls="false" vg-loop="true"></vg-media></videogular><button ng-click="test()">test</button>',
link: function (scope) {
scope.$API = null;
scope.onPlayerReady = function($API) {
console.log("tell me you're there");
scope.$API = $API;
};
scope.test = function(){
scope.$API.play();
};
}
};
完整代码笔:http://codepen.io/anon/pen/dMKKbX
在SO上还有另一个可能相关的问题:stop other video that is playing in background on play the new one
如上所述,对Github的讨论:https://github.com/videogular/videogular/issues/59