Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var YouTubeFlashVideo = function() {
- var params = {
- allowScriptAccess: "always",
- bgcolor: "#000000",
- wmode: "opaque"
- };
- var attributes = {
- id: "player",
- };
- this.setVideo = function( id ) {
- this.lastStartTime = null;
- this.videoId = id;
- var url = 'https://youtube.googleapis.com/yva_video?enablejsapi=1&autoplay=1&fs=1&hl=en&modestbranding=1&autohide=1&showinfo=0&controls=0';
- if ( theater.isCCEnabled() ) {
- url += "&cc_load_policy=1";
- url += "&yt:cc=on";
- }
- if (id.length > 11) {
- url += '&docid=' + id + '&ps=docs&partnerid=30';
- }
- swfobject.embedSWF(url, "player", "126.6%", "104.2%", "9", null, null, params, attributes);
- }
- this.setVolume = function( volume ) {
- this.lastVolume = null;
- this.volume = volume;
- };
- this.setStartTime = function( seconds ) {
- this.lastStartTime = null;
- this.startTime = seconds;
- };
- this.seek = function( seconds ) {
- if ( this.player != null ) {
- this.player.seekTo( seconds, true );
- if ( this.player.getPlayerState() != 1 ) {
- this.player.playVideo();
- }
- }
- };
- this.onRemove = function() {
- clearInterval( this.interval );
- };
- this.getCurrentTime = function() {
- if ( this.player != null ) {
- return this.player.getCurrentTime();
- }
- };
- this.think = function() {
- if ( this.player != null ) {
- if ( (typeof(this.player.getPlayerState) === "function") && this.player.getPlayerState() != -1 ) {
- if ( this.startTime != this.lastStartTime ) {
- this.seek( this.startTime );
- this.lastStartTime = this.startTime;
- }
- if ( this.volume != this.player.getVolume() ) {
- this.player.setVolume( this.volume );
- this.volume = this.player.getVolume();
- }
- }
- }
- };
- this.onReady = function() {
- this.player = document.getElementById('player');
- this.player.style.marginLeft = "-24.2%";
- this.player.style.marginTop = "-2%";
- this.ytforceres="large";
- if (theater.isHDEnabled()) {
- this.ytforceres = "hd720";
- }
- if (this.videoId.length <= 11) {
- this.player.loadVideoById( this.videoId, this.startTime, this.ytforceres);
- this.lastStartTime = this.startTime;
- } else {
- this.player.setPlaybackQuality(this.ytforceres);
- }
- var self = this;
- this.interval = setInterval( function() { self.think(self); }, 100 );
- };
- };
- registerPlayer( "youtube", YouTubeFlashVideo );
- registerPlayer( "drive", YouTubeFlashVideo );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement