1 function YouTube(options) {
2 this.options = options;
3 this.wrapper = options.wrapper;
4 this.link = this.wrapper.find('a');
5 this.image = this.wrapper.find('img');
6 this.videoEl = this.wrapper.find('.player-placeholder');
7 this.currwidth = this.wrapper.width();
8 this.currheight = parseInt(458* (this.currwidth/816));
11 this.player = new YT.Player(this.videoEl[0], {
12 height: self.currheight,
13 width: self.currwidth,
14 playerVars: { 'modestbranding':1},
15 videoId: options.youtube_id,
16 suggestedQuality: 'hd1080',
18 'onStateChange': function(event) {
19 if ( event.data == YT.PlayerState.ENDED ) {
25 console.log(this.player);
26 // this.player.setPlaybackQuality('hd1080');
33 YouTube.prototype.initEvents = function() {
35 this.link.click(function(e){
37 self.image.fadeOut({duration:2500,easing:'easeOutCirc'});
38 $(self.player.a).hide().fadeIn({duration:3500,easing:'easeOutCirc'});
39 self.wrapper.animate({
40 height: self.currheight
43 self.player.setPlaybackQuality('hd1080');
44 self.player.playVideo();
47 $('.stop-youtube').click(function(e){
53 YouTube.prototype.endEvents = function() {
56 self.image.fadeIn({duration:1500,easing:'easeOutCirc'});
57 $(self.player.a).show().fadeIn({duration:1500,easing:'easeOutCirc'});
58 self.wrapper.animate({