/** * DivX Plus Web Player Javascript Library * * @file dwpJsLib.js * @version 0.75 * @author DivX Inc. * @copyright Copyright (c) 2010, DivX Inc. * @link http://developer.divx.com/ */ /* Check if jQuery is already loaded and load it isn't */ if (typeof jQuery == 'undefined') { document.write(""); } /** * Add Prototype method to String * This method return an object containing the parsed version from the String * * Usage Example: * * var myVersionStr="1.0.3.275"; * var myVersionObj=myVersionStr.versionStringToObject(); * * for (var k in myVersionObj) { * document.write(k + '=' + myVersionObj[k]); * } * * Will return: * * major=1 minor=0 patch=3 build=275 * */ String.prototype.versionStringToObject = function(){ var x = this.split('.'); // parse from string or default to 0 if can't parse var maj = parseInt(x[0]) || 0; var min = parseInt(x[1]) || 0; var pat = parseInt(x[2]) || 0; var bui = parseInt(x[3]) || 0; return { major: maj, minor: min, patch: pat, build: bui, } } /** * Add Prototype method to String * This method return true if the string containing a version meet minimumVersion provided as a parameter * * Usage Example: * * var myVersionStr="1.1.3.275"; * * document.write(myVersionStr.StringVersionMeetMinimum('1.0'); * * Will return: * * true * */ String.prototype.StringVersionMeetMinimum = function(versionReference){ minimum = versionReference.versionStringToObject(); running = this.versionStringToObject(); if (running.major != minimum.major) return (running.major > minimum.major); else { if (running.minor != minimum.minor) return (running.minor > minimum.minor); else { if (running.patch != minimum.patch) return (running.patch > minimum.patch); else { if (running.build != minimum.build) return (running.build > minimum.build); else return true; } } } } /** * Will hold collection of all embeds in the page */ function DwpEmbedCollection(){ this.embedList = []; this.currentlyPlaying; this.showAdOffsetSeconds; this.initAllCallbacks = function(){ for (a = 0; a < this.embedList.length; a++) { if (this.embedList[a].plugin == null) { this.embedList[a].initCallback(a); } } } } /* The collection containing all embed in the page is held in this object */ var dwpEmbedCollection = new DwpEmbedCollection(); function dwpPlayer(embedWidth, embedHeight){ /* Initialize private variables */ var libraryURL = 'http://divxweb.googlecode.com/files/'; //var fauxImages = libraryURL + 'images/'; // Set folder (or URL prefix) for images var fauxImages = libraryURL; //Googlecode doesnt allow folder creation var userAgent = navigator.userAgent; /* Initialize public variables */ this.embedDiv; this.playerContainer; this.embedCollectionId; this.timeLeft = 0; /* Embed Parameters */ this.width = embedWidth; this.height = embedHeight; this.url; this.mode; this.minVersion; this.allowContextMenu; this.autoPlay; this.loop; this.bannerEnabled; // this.bufferingMode; /* Deprecated */ this.movieTitle; this.previewMessage; this.previewMessageSize; this.previewImage; this.enableDebug; this.videoResumeOverlayText this.isFullScreen = false; //used to determine if need to return in full screen after ad finish /* Ad Section */ this.adUnitId; this.adServer; this.adType; this.adHtmlCode; this.adContainer; this.adDuration; this.adStartOffsetSeconds; this.adStartOffsetPercent; this.adRequestUrl; this.enableAdvertisement; /* Google Analytics */ this.enableAnalytics; this.googleAnalyticsId; this.adCampaign; this.adLanguage; this.pageTracker; this.adShown = false; /* will hold the plugin object */ this.plugin; /* Add inline CSS styles */ /* fauxPlayer style */ var styles = ".fauxPlayer { position: relative; }" + ".popupHolder { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: block; }" + /* Used for centering */ ".popup { position: absolute; top:0; bottom:0; left:0; right:0; margin: auto; height: 150px; width: 300px; } " + /* Centering */ ".popup { font-family: Calibri, Arial, Sans-Serif; font-size: 12px; color: White; border: }" + ".popup img.dialog { position: absolute; top: 0; left: 0; z-index: 10; display: block; }" + ".popup .message { width: 260px; height: 150px; position: absolute; top: 0; left: 20px; z-index: 20; }" + ".popup .message h1 { font-size: 16px; margin: 10px 0 0 0 !important; padding: 0 !important; color: white !important; background: none !important; }" + ".popup .message p {font-size: 12px;line-height:100%; color: white !important; }" + ".popup .message input { font-size: 12px; background: !important; border: !important; }" + ".previewImage { display: block; }" + ".bar { width: 100%; height: 20px; margin: 0; padding: 0; position: relative; background-image: url(" + fauxImages + "dwp-progress-light.png); }" + ".barLeft { position: absolute; left: 0; top: 0; }" + ".barRight { position: absolute; right: 0; top: 0; }" + ".directLink img { border: 0 none !important; margin: 0 !important; padding: 0 !important; }"; /* PS3 specific styles */ if (this.type == 'ps3') { styles += ".popupHolder { text-align: center !important; }" + ".popup { position: static !important; margin-top: 8% !important; }" + ".popup img.dialog { position: static !important; }"; } styles += '.btn_download a:hover{color: #97c2ca; text-decoration: underline;}' + '.btn_download a:link, .btn_download a:visited {background-color: transparent;background-image: url("' + fauxImages + 'btn_std_download_lt.png"); background-repeat: no-repeat; height: 44px;line-height: 48px;' + 'color: #ffffff;text-decoration: none;font-size: 14px;text-align: center;display: block;padding-top: 0pt;' + 'padding-right: 7px;padding-bottom: 0pt;padding-left: 45px;float: left;}'; /* Ad section style */ styles += ".divjsAdContainer { position: absolute; overflow: hidden; text-align: center; display: none; float: left; z-index:5; }" + ".divjsPlayerContainer { position: relative; float: left; } " + ".divjsAdContainer a img { border: none; }" + ".timeLeftMessage { position: absolute; top: 400px; left: 0px; width: 100%; letter-spacing: -1px; color: white;" + " font: 24px / 45px Berlin Sans FB, Sans-Serif; background: #4A4D4A; padding: 10px; -khtml-opacity:0.6; opacity: 0.6; line-height:90%; }" + ".dwpDebugConsoleHeader { font-size: 150%; width: 700px; font-weight:bolder; margin:5px 0 5px 0; text-align:center; }" + ".dwpjsConsole { background-color:000000; color:lime; width: 700px; height: 200px; overflow: scroll; }"; document.write(""); /* Creates the appropriate "player" based on device */ this.create = function(divToUpdate){ /* Detect Style if required */ this.type = this.type.toLowerCase(); if (this.type != 'mobile' && this.type != 'ps3') { this.detectBrowser(); } /* Plug-in detection */ plug = this.detectWebPlayerPlugin(); if ((this.type != 'mobile' && this.type != 'ps3' && this.type != 'linux') && (Boolean(plug.installed) != true || plug.version.StringVersionMeetMinimum('2.0.2') != true)) { htmlCode = this.offerWebPlayerDownload(plug.installed); } else { this.loadBit_ly(this.bitlyLogin, this.bitlyAPIkey); if (!document.body && (this.enableAdvertisement == true || this.enableAdvertisement == 'true')) { this.enableAdvertisement = false; document.write('

Error! the document doesnt have body tags, advertisement will not work.

'); } if (this.adServer) this.enableAdvertisement = true; this.embedDiv = divToUpdate; this.playerContainer = divToUpdate + '_player'; this.adContainer = divToUpdate + '_ad'; this.setMissingValues(); this.embedCollectionId = dwpEmbedCollection.embedList.length; dwpEmbedCollection.embedList[this.embedCollectionId] = this; if (this.enableAnalytics == true || this.enableAnalytics == 'true') { try { this.pageTracker = _gat._getTracker(this.googleAnalyticsId); this.pageTracker._trackPageview(); } catch (err) { this.enableAnalytics = false; document.write('

Error! Google Analytics cannot be activated, make sure "ga.js" is loaded.

'); } } this.type = this.type.toLowerCase(); switch (this.type) { case 'linux': htmlCode = this.createLinuxPlayer(); if (this.pageTracker) { /* Ping analytics */ this.pageTracker._trackEvent('DivX Plus Embed', 'LINUX_EMBED_DISPLAYED', this.url); } break; case 'ps3': htmlCode = this.createPS3Player(); if (this.pageTracker) { /* Ping analytics */ this.pageTracker._trackEvent('DivX Plus Embed', 'PS3_EMBED_DISPLAYED', this.url); } break; case 'mobile': htmlCode = this.createMobilePlayer(); if (this.pageTracker) { /* Ping analytics */ this.pageTracker._trackEvent('DivX Plus Embed', 'MOBILE_EMBED_DISPLAYED', this.url); } break; default: case 'standard': this.type = 'standard'; htmlCode = this.createStandardPlayer(); if (this.pageTracker) { /* Ping analytics */ this.pageTracker._trackEvent('DivX Plus Embed', 'STANDARD_EMBED_DISPLAYED', this.url); } break; } } this.setDivDimension(divToUpdate); if (this.enableDebug == true || this.enableDebug == 'true') htmlCode += "
Debug Console