Is vg-complete called?
ronky opened this issue · comments
ronky commented
Hi,
when youtube video is finished playing, is the method in vg-complete called?
<videogular vg-theme="videoConfig.theme.url" class="videogular-container" vg-complete="onCompleteVideoPlay()" vg-player-ready="onPlayerReady($API)">
<vg-media vg-src="videoConfig.sources" vg-youtube="rel=1;showinfo=1"></vg-media>
</videogular>
$scope.onCompleteVideoPlay = function () {
if (secondScreenCtrl.API) {
secondScreenCtrl.API.toggleFullScreen();
$scope.playingVideo = false;
} else {
throw new Error('video player API not ready!');
}
};
DerekNien commented
I think it won't call the method in vg-complete.
Since the author did not register YouTube API's onStateChange
event (See YouTube IFrame API) and trigger the ended event when the YouTube video ends. The ended event is listened by API.mediaElement[0]
(See vg-controller.js). So the onComplete
API event handler of videogular (See vg-controller.js) won't be called and hence the method in vg-complete won't be called, either.
ronky commented
Thanks @DerekNien for pointing me in the right direction.
DerekNien commented
You're welcome. :)
And thank you for your pull request.