src/js/libs/popcorn.youtube.js
author hamidouk
Mon, 19 Dec 2011 15:25:22 +0100
branchpopcorn-port
changeset 481 a46cfeee6d77
parent 110 048125f1a167
permissions -rw-r--r--
using jquery ui draggable changes the state of an element from absolute to relative positioning, which breaks the way our seek button expands itself, so we need to force absolute positioning, quite uglily, using jquery.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
110
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
     1
// A global callback for youtube... that makes me angry
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
     2
var onYouTubePlayerReady = function( containerId ) {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
     3
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
     4
  onYouTubePlayerReady[ containerId ] && onYouTubePlayerReady[ containerId ]();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
     5
};
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
     6
onYouTubePlayerReady.stateChangeEventHandler = {};
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
     7
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
     8
Popcorn.player( "youtube", {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
     9
  _setup: function( options ) {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    10
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    11
    var media = this,
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    12
        youtubeObject,
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    13
        container = document.createElement( "div" ),
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    14
        currentTime = 0,
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    15
        seekTime = 0,
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    16
        seeking = false,
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    17
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    18
        // state code for volume changed polling
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    19
        volumeChanged = false,
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    20
        lastMuted = false,
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    21
        lastVolume = 0;
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    22
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    23
    container.id = media.id + Popcorn.guid();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    24
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    25
    media.appendChild( container );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    26
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    27
    var youtubeInit = function() {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    28
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    29
      var flashvars,
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    30
          params,
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    31
          attributes,
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    32
          src;
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    33
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    34
      // expose a callback to this scope, that is called from the global callback youtube calls
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    35
      onYouTubePlayerReady[ container.id ] = function() {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    36
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    37
        youtubeObject = document.getElementById( container.id );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    38
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    39
        // more youtube callback nonsense
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    40
        onYouTubePlayerReady.stateChangeEventHandler[ container.id ] = function( state ) {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    41
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    42
          // playing is state 1
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    43
          // paused is state 2
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    44
          if ( state === 1 ) {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    45
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    46
            media.paused && media.play();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    47
          // youtube fires paused events while seeking
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    48
          // this is the only way to get seeking events
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    49
          } else if ( state === 2 ) {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    50
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    51
            // silly logic forced on me by the youtube API
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    52
            // calling youtube.seekTo triggers multiple events
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    53
            // with the second events getCurrentTime being the old time
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    54
            if ( seeking && seekTime === currentTime && seekTime !== youtubeObject.getCurrentTime() ) {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    55
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    56
              seeking = false;
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    57
              youtubeObject.seekTo( currentTime );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    58
              return;
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    59
            }
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    60
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    61
            currentTime = youtubeObject.getCurrentTime();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    62
            media.dispatchEvent( "timeupdate" );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    63
            !media.paused && media.pause();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    64
          }
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    65
        };
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    66
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    67
        // youtube requires callbacks to be a string to a function path from the global scope
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    68
        youtubeObject.addEventListener( "onStateChange", "onYouTubePlayerReady.stateChangeEventHandler." + container.id );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    69
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    70
        var timeupdate = function() {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    71
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    72
          if ( !media.paused ) {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    73
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    74
            currentTime = youtubeObject.getCurrentTime();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    75
            media.dispatchEvent( "timeupdate" );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    76
            setTimeout( timeupdate, 10 );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    77
          }
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    78
        };
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    79
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    80
        var volumeupdate = function() {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    81
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    82
          if ( lastMuted !== youtubeObject.isMuted() ) {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    83
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    84
            lastMuted = youtubeObject.isMuted();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    85
            media.dispatchEvent( "volumechange" );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    86
          }
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    87
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    88
          if ( lastVolume !== youtubeObject.getVolume() ) {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    89
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    90
            lastVolume = youtubeObject.getVolume();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    91
            media.dispatchEvent( "volumechange" );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    92
          }
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    93
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    94
          setTimeout( volumeupdate, 250 );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    95
        };
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    96
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    97
        media.play = function() {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    98
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
    99
          media.paused = false;
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   100
          media.dispatchEvent( "play" );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   101
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   102
          media.dispatchEvent( "playing" );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   103
          timeupdate();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   104
          youtubeObject.playVideo();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   105
        };
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   106
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   107
        media.pause = function() {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   108
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   109
          if ( !media.paused ) {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   110
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   111
            media.paused = true;
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   112
            media.dispatchEvent( "pause" );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   113
            youtubeObject.pauseVideo();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   114
          }
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   115
        };
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   116
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   117
        Popcorn.player.defineProperty( media, "currentTime", {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   118
          set: function( val ) {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   119
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   120
            // make sure val is a number
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   121
            currentTime = seekTime = +val;
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   122
            seeking = true;
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   123
            media.dispatchEvent( "seeked" );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   124
            media.dispatchEvent( "timeupdate" );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   125
            youtubeObject.seekTo( currentTime );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   126
            return currentTime;
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   127
          },
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   128
          get: function() {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   129
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   130
            return currentTime;
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   131
          }
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   132
        });
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   133
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   134
        Popcorn.player.defineProperty( media, "muted", {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   135
          set: function( val ) {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   136
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   137
            if ( youtubeObject.isMuted() !== val ) {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   138
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   139
              if ( val ) {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   140
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   141
                youtubeObject.mute();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   142
              } else {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   143
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   144
                youtubeObject.unMute();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   145
              }
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   146
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   147
              lastMuted = youtubeObject.isMuted();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   148
              media.dispatchEvent( "volumechange" );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   149
            }
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   150
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   151
            return youtubeObject.isMuted();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   152
          },
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   153
          get: function() {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   154
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   155
            return youtubeObject.isMuted();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   156
          }
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   157
        });
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   158
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   159
        Popcorn.player.defineProperty( media, "volume", {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   160
          set: function( val ) {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   161
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   162
            if ( youtubeObject.getVolume() !== val ) {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   163
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   164
              youtubeObject.setVolume( val );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   165
              lastVolume = youtubeObject.getVolume();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   166
              media.dispatchEvent( "volumechange" );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   167
            }
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   168
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   169
            return youtubeObject.getVolume();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   170
          },
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   171
          get: function() {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   172
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   173
            return youtubeObject.getVolume();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   174
          }
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   175
        });
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   176
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   177
        media.readyState = 4;
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   178
        media.dispatchEvent( "load" );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   179
        media.duration = youtubeObject.getDuration();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   180
        media.dispatchEvent( "durationchange" );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   181
        volumeupdate();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   182
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   183
        media.dispatchEvent( "loadeddata" );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   184
      };
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   185
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   186
      options.controls = +options.controls === 0 || +options.controls === 1 ? options.controls : 1;
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   187
      options.annotations = +options.annotations === 1 || +options.annotations === 3 ? options.annotations : 1;
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   188
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   189
      flashvars = {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   190
        playerapiid: container.id,
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   191
        controls: options.controls,
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   192
        iv_load_policy: options.annotations
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   193
      };
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   194
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   195
      params = {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   196
        wmode: "transparent",
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   197
        allowScriptAccess: "always"
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   198
      };
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   199
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   200
      attributes = {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   201
        id: container.id
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   202
      };
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   203
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   204
      src = /^.*[\/=](.{11})/.exec( media.src )[ 1 ];
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   205
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   206
      swfobject.embedSWF( "http://www.youtube.com/e/" + src + "?enablejsapi=1&playerapiid=" + container.id + "&version=3",
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   207
                          container.id, media.offsetWidth, media.offsetHeight, "8", null,
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   208
                          flashvars, params, attributes );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   209
    };
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   210
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   211
    if ( !window.swfobject ) {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   212
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   213
      Popcorn.getScript( "http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js", youtubeInit );
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   214
    } else {
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   215
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   216
      youtubeInit();
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   217
    }
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   218
  }
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   219
});
048125f1a167 moved external libraries to their own subdir.
hamidouk
parents:
diff changeset
   220