changing player-vars model
opened this issue · comments
i have a button that toggles the loop option in the player-vars model but doesnt take effect unless it is loaded the first time. how can i make it so it is 2 way binding
unfortunately, with the underlying YouTube API, i'm not sure there's good way to make player-vars
values update live
however, instead of the loop
option, you could do something like this
$scope.$on('youtube.player.ended', function ($event, player) {
if (options.shouldLoop) {
// play it again
player.playVideo()
}
});
does that work for you?
ya i do a similar thing. but i write my function inside the angular-youtube-embed.js. if you put this inside the library it wuld make it easier . i have done my own fork though.
function onPlayerStateChange(event) {
/*.......*/
if (state == 'ended') {
if(scope.playerVars.loop) {
scope.player.playVideo();
}
}
/*.......*/
}
i'd recommend doing it outside the library, since you won't be able to take advantage of future versions of this library and bug fixes. i'm glad you got it working tho!