NamPNQ / bower-videogular-youtube

Videogular `youtube` plugin repository for distribution on `bower`
MIT License
41 stars 32 forks source link

Is vg-complete called? #24

Closed ronky closed 9 years ago

ronky commented 9 years ago

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 9 years ago

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 9 years ago

I've created a pull request https://github.com/NamPNQ/bower-videogular-youtube/pull/26

ronky commented 9 years ago

Thanks @DerekNien for pointing me in the right direction.

DerekNien commented 9 years ago

You're welcome. :) And thank you for your pull request.