(function () {
    'use strict';

    angular.module('videoRental').controller('MoviePageController', function( $scope, $stateParams, CatalogueService ) {
        $scope.getMovie = function(movieId) {
            $scope.ajax = true;
    		CatalogueService.getMovie(movieId)
    			.then(function (response) {
    				console.log('response', response);
                    $scope.movie = response;
                    $scope.ajax = false;
                }).catch(function(response) {
                    console.error(response);
                    $scope.ajax = false;
                });
    	};

        $scope.$on('youtube.player.playing', function ($event, player) {
            console.log('CHARGE ME!!!');
        });

    	$scope.getMovie($stateParams.movieId);
    });
})();