NamPNQ / bower-videogular-youtube

Videogular `youtube` plugin repository for distribution on `bower`

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is vg-complete called?

ronky opened this issue · comments

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!');
                }
};

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.

commented

I've created a pull request #26

commented

Thanks @DerekNien for pointing me in the right direction.

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