angular.module('youtube', ['ng']).run(function () {
    var tag = document.createElement('script');

    // This is a protocol-relative URL as described here:
    //     http://paulirish.com/2010/the-protocol-relative-url/
    // If you're testing a local page accessed via a file:/// URL, please set tag.src to
    //     "https://www.youtube.com/iframe_api" instead.
    tag.src = "//www.youtube.com/iframe_api";
    var firstScriptTag = document.getElementsByTagName('script')[0];
    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
    })
.service('youtubePlayerApi', ['$window', '$rootScope', '$log', function ($window, $rootScope, $log) {
    var service = $rootScope.$new(true);

    // Youtube callback when API is ready
    $window.onYouTubeIframeAPIReady = function () {
        $log.info('Youtube API is ready');
        service.$apply(function () {
            service.ready = true;
        });
    };

    service.ready = false;
    service.playerId = null;
    service.player = null;
    service.videoId = null;
    service.playerHeight = '390';
    service.playerWidth = '640';

    service.bindVideoPlayer = function (elementId) {
        $log.info('Binding to player ' + elementId);
        service.playerId = elementId;
    };

    service.createPlayer = function () {
        $log.info('Creating a new Youtube player for DOM id ' + this.playerId + ' and video ' + this.videoId);
        return new YT.Player(this.playerId, {
            height: this.playerHeight,
            width: this.playerWidth,
            videoId: this.videoId
        });
    };

    service.loadPlayer = function () {
        // API ready?
        if (this.ready && this.playerId && this.videoId) {
            if(this.player) {
                this.player.destroy();
            }

            this.player = this.createPlayer();
        }
    };

    return service;
}])
.directive('youtubePlayer', ['youtubePlayerApi', function (youtubePlayerApi) {
    return {
        restrict: 'EA',
        scope: {
            videoId: '='
        },
        link: function (scope, element, attrs) {
            // Attach to element
            youtubePlayerApi.bindVideoPlayer(element[0].id);

            // Allow us to watch 'player.ready'
            scope.player = youtubePlayerApi;
            var stopWatchingReady = scope.$watch('player.ready',
                function (ready) {
                    if (ready) {
                        stopWatchingReady();

                        // Change video, load player
                        scope.$watch('videoId', function (id) {
                            youtubePlayerApi.videoId = id;
                            youtubePlayerApi.loadPlayer();
                        });
                    }
            });
        }
    };
}]);

@@ -542,20 +542,16 @@
 ptTag);%0A
-    
 %7D)%0A.serv
@@ -603,16 +603,8 @@
 pe',
- '$log',
  fun
@@ -633,14 +633,8 @@
 cope
-, $log
 ) %7B%0A
@@ -655,64 +655,26 @@
 e = 
-$rootScope.$new(true);%0A%0A    // Youtube callback when API
+%7B%0A        // Frame
  is 
@@ -687,313 +687,219 @@
     
+ 
-$window.onYouTubeIframeAPIReady = function () %7B%0A        $log.info('Youtube API is ready');%0A        service.$apply(function () %7B%0A            service.ready = true;%0A        %7D);%0A    %7D;%0A%0A    service.ready = false;%0A    service.playerId =
+   ready: false,%0A%0A        // Element id for player%0A        playerId: null,%0A%0A        // Player currently in use%0A        player: null,%0A%0A        // Current video id%0A        videoId:
  null
-;
+,%0A
 %0A    
-service.player = null;%0A    service.videoId = null;%0A    service.
+    // Size%0A        
 play
@@ -910,30 +910,25 @@
 ight
- =
+:
  '390'
-;
+,
 %0A    
-service.
+    
 play
@@ -938,183 +938,26 @@
 idth
- =
+:
  '640'
-;%0A%0A    service.bindVideoPlayer = function (elementId) %7B%0A        $log.info('Binding to player ' + elementId);%0A        service.playerId = elementId;%0A    %7D;%0A%0A    service.
+,%0A%0A        
 crea
@@ -960,26 +960,25 @@
 createPlayer
- =
+:
  function ()
@@ -988,115 +988,8 @@
     
-    $log.info('Creating a new Youtube player for DOM id ' + this.playerId + ' and video ' + this.videoId);%0A
     
@@ -1042,16 +1042,20 @@
         
+  
+  
 height: 
@@ -1085,16 +1085,20 @@
         
+    
 width: t
@@ -1118,32 +1118,36 @@
 th,%0A            
+ 
+   
 videoId: this.vi
@@ -1152,16 +1152,20 @@
 videoId%0A
+    
         
@@ -1176,24 +1176,23 @@
     
-%7D;%0A%0A    service.
+    %7D,%0A        
 load
@@ -1197,18 +1197,17 @@
 adPlayer
- =
+:
  functio
@@ -1221,26 +1221,8 @@
     
-    // API ready?%0A
     
@@ -1288,16 +1288,20 @@
         
+   
+ 
 if(this.
@@ -1306,24 +1306,28 @@
 s.player) %7B%0A
+    
             
@@ -1369,11 +1369,19 @@
     
+  
+  
 %7D%0A%0A
+    
     
@@ -1423,33 +1423,235 @@
 ayer();%0A        
+ 
-%7D
+   %7D%0A        %7D%0A    %7D;%0A%0A    // Youtube callback when API is ready%0A    $window.onYouTubeIframeAPIReady = function () %7B%0A        $rootScope.$apply(function () %7B%0A            service.ready = true;%0A        %7D);
 %0A    %7D;%0A%0A    ret
@@ -1951,24 +1951,19 @@
 Api.
-bindVideoPlayer(
+playerId = 
 elem
@@ -1971,17 +1971,16 @@
 nt%5B0%5D.id
-)
 ;%0A%0A     

clean up the code, no need to create a scope in there