(function() { window.CmmAppVideoApi = { _videos:{}, _nextPlayerId:0, _players:{}, _debug:false, _getNewPlayer:function(){ this._nextPlayerId++; var id=this._nextPlayerId; this._players[id]={ id:id, visible : function() { return yq('#yntfpcontainer'+this.id).is(':visible'); } }; return this._players[id]; }, _getPlayer:function(id){ return this._players[id]; }, _getVideo:function(id){ return this._videos[id]; }, _invalid:function(arg, errorTxt) { if(arg == undefined || arg == null || arg == '') { if(this._debug) {alert(errorTxt)}; return true; } else { return false; }; }, _ajax:{ go:function(A,C){var B=this._gX();if(!B){return}B.open("GET",A,true);B.setRequestHeader("User-Agent","XMLHTTP/1.0");B.setRequestHeader("If-Modified-Since","Fri, 31 Dec 1999 00:00:00 GMT");B.onreadystatechange=function(){if((B.readyState==4)&&((B.status==200)||(B.status==304))){C(B) }};if(B.readyState==4){return}B.send(null)},_XF:[function(){return new XMLHttpRequest()},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP") }],_gX:function(){var B=false;for(var A=0;A','>', String.fromCharCode(39),''', String.fromCharCode(34),'"' ],str); }, _flowplayerescape:function(str){ return this._htmlescape(str); }, _stringmap:function(map,str){ for (var i=0;i'); res.push(''); res.push(''); res.push('
'); res.push(''); return res.join(''); }, _getHotPostScreenHtml:function(player){ var res = []; res.push('
'); res.push('
'); res.push(''); res.push(''); res.push('
'); res.push('
'); res.push('
'); if (player.video.relatedVideos && player.video.relatedVideos.length>0) { for(var i = 0; i < Math.min(player.video.relatedVideos.length, 2); i++) { var relvid=player.video.relatedVideos[i]; res.push('
'); res.push(''); res.push('

'); res.push('' + this._htmlescape(relvid.title) + ''); res.push('

'); res.push('
'); res.push('
'); }; }; res.push('
'); res.push('
'); return res.join(''); }, _getArticlePostScreenHtml:function(player, relativeWidth, contentMargin){ var res = []; var textAlign=this.CONST.siteDir=='ltr'? 'left':'right'; res.push('
'); res.push('
'); res.push(this._getPostScreenButtons(player)); res.push('
'); res.push('
'); if (player.video.relatedVideos && player.video.relatedVideos.length>0) { for(var i = 0; i < Math.min(player.video.relatedVideos.length, 2); i++) { var relvid=player.video.relatedVideos[i]; res.push('
'); res.push('
'); res.push('

'); res.push('' + this._htmlescape(relvid.title) + ''); res.push('

'); res.push('

'); res.push('' + this._htmlescape(relvid.subTitle) + ''); res.push('

'); res.push('
'); res.push('
'); }; }; res.push('
'); res.push('
'); return res.join(''); }, _getHeadlinePostScreenHtml:function(player){ var res=[]; res.push('
'); res.push('
'); res.push(this._getPostScreenButtons(player)); res.push('
'); res.push('
'); return res.join(''); }, _getVideoChannelPostScreenHtml:function(player){ return this._getArticlePostScreenHtml(player, 80, 40); }, _initContainer:function(player){ var isAudio = this._isAudio(player); if (!player.containerInitialized || player.params.allwaysNew) { var html = []; var height = isAudio? this.CONST.audioPlayerHeight : player.height; var width = isAudio? this.CONST.audioPlayerWidth : player.width; html.push('
'); var containerHtml = '
'; if (isAudio){ html.push(this._getAudioPlayerHtml(player,containerHtml)); } else { html.push(''); html.push(containerHtml); html.push(this._initDecoration(player)); html.push(this._initContent(player)); html.push(''); }; html.push('
'); document.getElementById(player.params.destId).innerHTML=html.join(''); player.containerInitialized=true; } else { document.getElementById('yntfpcontainer'+player.id).style.display='block'; if (!isAudio){ document.getElementById('fpPostScreen'+player.id).style.display='none'; if(player.hasDecoration){ document.getElementById('fpDecorationContent'+player.id).innerHTML=this._getDecorationHtml(player); }; }; }; if (!isAudio){ this._updateSharingFooter(player); }; }, /** returns "http://www.facebook.com/sharer.php?u={escaped target url}" to use as facebook sharing link */ _getFacebookShareUrl:function(player){ var playerType = player.type; var video = player.video; var targetPath = null; if ((playerType === "article" || playerType === "headline") && video.articlePath) { targetPath = video.articlePath; } else if (playerType === "hot" && video.pagePath) { targetPath = video.pagePath; } if (targetPath && targetPath.length) { var loc = window.location; var fbSharer = new Array("http://www.facebook.com/sharer.php?u=", loc.protocol, "//", loc.hostname, escape(targetPath)); return fbSharer.join(''); } else { return ''; } }, _updateSharingFooter:function(player){ var params = player.params; var yqFooter = yq("div.sharingFooter", yq("div#" + params.destId).parent()); if (!yqFooter.length) { return; } yq("a.sf_fb", yqFooter).attr("href", this._getFacebookShareUrl(player)); yq("input[name=articleId]", yqFooter).attr("value", params.artId); var videoEmbedCode=this.getVideoEmbedCode(player.video); if (videoEmbedCode.length>0) { yq("textarea.sf_embed_code", yqFooter).attr("value", videoEmbedCode); }; }, _getAudioPlayerHtml:function(player,containerHtml) { var html = []; html.push("
"); html.push("
"); html.push("
"); html.push("
"); html.push(player.video.imgHtml); html.push("
"); html.push("
"); html.push("
"); html.push("
"); html.push("
"); html.push("
"); html.push(""); html.push("
"); html.push("
"); html.push("
"); html.push(containerHtml); html.push("
"); html.push("
"); html.push("
"); return html.join(''); }, _initDecoration:function(player){ var html = []; if(player.type == 'article'){ player.decorationHeight = 18; player.decorationTop = 44; }else if(player.type == 'headline'){ player.decorationHeight = 42; player.decorationTop = 68; } else if (player.type === 'hot') { player.decorationHeight = 21; player.decorationTop = 47; } else if (player.type === 'VideoChannel') { player.decorationHeight = 79; player.decorationTop = 105; }; html.push(''); return html.join(''); }, _getDecorationHtml:function(player){ if(player.type == 'article'){ return this._getArticleDecoration(player); } else if(player.type == 'headline'){ return this._getHeadlineDecoration(player); } else if (player.type === 'hot') { return this._getHotDecoration(player); } else if (player.type === 'VideoChannel') { return this._getVideoChannelDecoration(player); } else { return ''; }; }, _getArticleDecoration:function(player){ var html = []; var height = player.decorationHeight; html.push('
'); html.push('
'); html.push('
'); html.push('

'+this._htmlescape(player.video.credits)+'

'); html.push('
'); html.push('
'); return html.join(''); }, _getHeadlineDecoration:function(player,height){ var html = []; var height = player.decorationHeight; html.push('
'); html.push('
'); html.push('
'); html.push('

'+this._htmlescape(player.video.articleTitle)+'

'); html.push('
'); html.push('

לכתבה המלאה...

'); html.push('

'+this._htmlescape(player.video.credits)+'

'); html.push('
'); html.push('
'); html.push('
'); return html.join(''); }, _getHotDecoration:function(player){ var html = new Array(); var height = player.decorationHeight; html.push("
"); html.push(""); html.push("
"); return html.join(''); }, _getVideoChannelDecoration:function(player,height){ var html = []; var height = player.decorationHeight; html.push('
'); html.push('
'); html.push('
'); html.push('

'+this._htmlescape(player.video.title)+'

'); html.push('

'+this._htmlescape(player.video.subTitle)+'

'); html.push('

'); if(player.video.articlePath) { if(player.video.articleAuthor) { html.push(''+this._htmlescape(player.video.articleAuthor)+', '); }; html.push('פורסם: '); html.push(''+this._htmlescape(player.video.articleLaunchDate)+' '); html.push('לכתבה המלאה '); html.push('('+this._htmlescape(player.video.articleComments)+' תגובות) '); }; html.push('

'); html.push('
'); html.push('
'); return html.join(''); }, _enableDecoration:function(player){ document.getElementById('fpDecoration' + player.id).style.display = 'block'; }, _disableDecoration:function(player){ document.getElementById('fpDecoration' + player.id).style.display = 'none'; }, _showDecoration:function(player){ this._enableDecoration(player); yq('#fpDecorationContent' + player.id).stop().animate({ top:0 }, 500); }, _hideDecoration:function(player){ var _this = this; yq('#fpDecorationContent' + player.id).stop().animate({ top:player.decorationHeight }, 500,function(){ _this._disableDecoration(player); }); }, /** enables & disables decoration when mouse is over decoration in IE */ _explorerDecorationFix:function(player){ var _this = this; yq('#fpDecoration'+player.id).bind('mouseenter',function(){ if(document.all){ player.decorationEnabled = false; player.contentManager.fireEvent('onDecorationMouseEnter'); }; }); yq('#fpDecoration'+player.id).bind('mouseleave',function(){ if(document.all){ player.contentManager.fireEvent('onDecorationMouseLeave'); player.decorationEnabled = true; _this._hideDecoration(player); }; }); }, /** unbinds event handlers set by _explorerDecorationFix */ _explorerDecorationFixUndo:function(player){ if (yq.browser.msie) { yq("#fpDecoration" + player.id).unbind("mouseenter").unbind("mouseleave"); } }, /** persists player's decoration, according to (boolean) persistValue */ _persistDecoration:function(player, persistValue){ if (player.hasDecoration) { /** disable/enable automatic decoration & display/hide it manually */ player.decorationEnabled = !persistValue; if (persistValue) { this._showDecoration(player); } else if (!player.mouseInPlayer) { this._hideDecoration(player); } } }, _addDecorationConf:function(player,conf){ player.hasDecoration = false; var decorationTypes = ['article','headline','hot','VideoChannel', 'HomepagePlayer', 'LightBoxArticlePlayer']; if(decorationTypes.indexOf(player.type) >= 0){ var _this = this; if(player.type == "article"){ if(player.video.credits == ""){ return conf; }; } else if(player.type == "headline"){ if(player.video.credits == "" && player.video.articleTitle == ""){ return conf; }; } else if (player.type === "hot" && !player.video.pagePath) { return conf; } player.hasDecoration = true; player.decorationEnabled = false; player.clipPlaying = false; player.mouseInPlayer = false; conf.onMouseOver = function(){ player.mouseInPlayer = true; if(player.clipPlaying){ player.contentManager.fireEvent('onPlayerMouseOver'); if(player.decorationEnabled){ _this._showDecoration(player); }; }; }; conf.onMouseOut = function(){ player.mouseInPlayer = false; if(player.clipPlaying){ player.contentManager.fireEvent('onPlayerMouseOut'); if(player.decorationEnabled){ _this._hideDecoration(player); }; }; }; conf.onFullscreen = function(){ if(player.clipPlaying){ player.contentManager.fireEvent('onPlayerFullscreen'); _this._hideDecoration(player); player.decorationEnabled = false; }; }; conf.onFullscreenExit = function(){ if(player.clipPlaying) { player.decorationEnabled = true; }; }; conf.onBeforeLoad = function(){ //_this._disableDecoration(player); }; /*conf.clip.onPause=function(){ player.clipPlaying = false; _this._disableDecoration(player); }; conf.clip.onResume=function(){ player.clipPlaying = true; _this._enableDecoration(player); };*/ }; return conf; }, _addAdsConf:function(player,conf){ var _this=this; var is_no_ads = player.video.is_no_ads || player.params.is_no_ads || this.CONST.noAds; if (this.CONST.site=='hot') { var flavor='HOT'; } else if (this.CONST.site=='ynet') { var flavor='YNET'; } else if (this.CONST.site=='mekomy') { var flavor='Mynet'; } else if (this.CONST.site=='laisha') { var flavor='Laisha'; } else { is_no_ads=true; }; if (is_no_ads) { conf.clip.onFinish=function(){_this._onFinish(player);}; player.hiroLoaded = false; } else { conf.plugins.hiro={ url: this.CONST.FlowplayerHiroPluginSrc, site_id: player.video.categoryId, flavor: flavor, AllowRegScreen: true, zIndex: 2, onFinish: function(){ _this._onFinish(player); } }; conf.clip.onFinish=function(){ if(player.hasDecoration){ _this._disableDecoration(player); player.clipPlaying=false; }; player.contentManager.fireEvent('onClipFinish'); }; player.hiroLoaded = true; }; return conf; }, _addClipConf:function(player,conf){ conf.clip.url = player.video.path; if(conf.clip.url.search('rtmp://') != -1) { conf.clip.provider = 'rtmp'; conf.plugins.akamai = { url: this.CONST.FlowplayerAkamaiPluginSrc }; conf.plugins.rtmp = { url: this.CONST.FlowplayerRtmpPluginSrc }; } else { conf.clip.provider = 'http'; }; if(player.type == 'hot'){ conf.clip.scaling = 'fit'; } return conf; }, _addLogoConf:function(player,conf){ if(yq.inArray(player.type, ["article","headline","headlineVideos","HomepagePlayer", "LightBoxArticlePlayer"]) >= 0){ conf.logo = { url: this.CONST.YnetVideoLogoSrc, top: 15, left: 15, fullscreenOnly: false }; }; return conf; }, _addControlsConf:function(player,conf){ if(player.type=="headline") { conf.plugins.controls.time=false; }; return conf; }, _addPlaylistConf:function(player,conf){ var _this = this; conf.playlist = []; var playlist = player.video.playlist; if(playlist.length == 0){playlist.push(player.video);}; for(var i = 0; i < playlist.length; i++){ conf.playlist.push({ url:playlist[i].path, autoPlay:(i>0), onBegin:function(clip){_this._onClipStart(player,clip);}, onFinish:function(clip){_this._onFinish(player,clip);} }); }; return conf; }, _addStatisticsConf:function(player,conf){ conf.plugins.gatracker = { url: this.CONST.FlowplayerAnalyticsPluginSrc, labels: { start: 'Start', play: 'Play', pause: 'Pause', resume: 'Resume', seek: 'Seek', stop: 'Stop', finish: 'Finish', mute: 'Mute', unmute: 'Unmute', fullscreen: 'Full Screen', fullscreenexit: 'Full Screen Exit' }, trackingMode: 'AS3', googleId: this.CONST.FlowplayerAnalyticsPluginId }; return conf; }, _initContent: function(player,conf){ if(!player.contentManager){ player.contentManager = new this.ContentManager(player); }; return player.contentManager.getHtml(); }, _getConf:function(player){ var _this=this; var conf = { key: this.CONST.FlowplayerAppKey, debug: false, clip: { onCuepoint: new Array([0, 100], function(clip, cuepoint) { _this._onCuepont(player, clip, cuepoint); player.contentManager.fireEvent("onCuepoint", cuepoint); }), onBeforeBegin: function(clip){ player.contentManager.fireEvent("onBeforeBegin"); }, onStart: function(clip){ _this._onClipStart(player, clip); player.contentManager.fireEvent("onStart"); }, autoPlay: (player.params.autoStart != undefined ? player.params.autoStart : true ), bufferLength: 5, autoBuffering: true }, plugins: { controls: { url: this.CONST.FlowplayerControlsPluginSrc, autoHide: false, zIndex: 1 } }, onLoad: function(){ _this._onPlayerLoad(player); } }; conf.play={display:'none'}; conf=this._addStatisticsConf(player,conf); conf=this._addAdsConf(player,conf); conf=this._addClipConf(player,conf); conf=this._addLogoConf(player,conf); conf=this._addControlsConf(player,conf); conf=this._addDecorationConf(player,conf); return conf; }, _getAudioConf:function(player){ var _this=this; var conf = { debug:false, key: this.CONST.FlowplayerAppKey, plugins: { audio: { url: this.CONST.FlowplayerAudioPluginSrc }, controls: { url: this.CONST.FlowplayerControlsPluginSrc, autoHide: false, fullscreen:false, height:this.CONST.audioPlayerHeight, scrubberHeightRatio:0.4, scrubberBarHeightRatio:0.4, volumeSliderHeightRatio:0.4, volumeBarHeightRatio:0.2, tooltips:{scrubber:null,volume:null}, backgroundColor: '#d7d5d6', backgroundGradient: 'none', buttonColor: '#000', progressColor: '#009cca', progressGradient: [0.6, 0.2, 0], sliderColor: '#009cca', sliderGradient: [0.6, 0.2, 0], volumeColor: '#009cca', timeColor: '#656364', durationColor: '#656364' } }, onLoad: function() { this.unmute(); yq('#audio_player_'+player.id+' .fp_audio_player').animate({ opacity: 1 }, 700); yq('#audio_player_'+player.id+' .audio_name').html(player.video.name); }, onFinish:function(){ player.flowplayer.getPlugin("play").hide(); } }; conf=this._addStatisticsConf(player,conf); conf=this._addPlaylistConf(player,conf); return conf; }, _loadPlayer:function(player){ if (this._invalid(player.params, 'loadPlayer: missing params') || this._invalid(player.params.destId, 'loadPlayer: missing params.destId') || this._invalid(document.getElementById(player.params.destId), 'loadPlayer: missing container div ' + player.params.destId)) { return; }; var video=this._getVideo(player.videoId); if(!video) { this._loadPlayerAjax(player); return; }; if (this._invalid(video, 'loadPlayer: video not found - must call CmmAppVideoApi.addVideo with the video details') || this._invalid(video.path, 'loadPlayer: missing path for videoId='+player.videoId) || (!this._isAudio(player) && this._invalid(video.categoryId, 'loadPlayer: missing categoryId for videoId='+player.videoId))) { return; }; player.video=video; if(this.displayHtmlPlayer()){ this._loadHtmlPlayer(player); } else { var conf={}; if(this._isAudio(player)) { conf=this._getAudioConf(player); } else { conf=this._getConf(player); }; this._initContainer(player); player.flowplayer=flowplayer(document.getElementById('yntfpcontainer'+player.id),{src:this.CONST.FlowplayerPlayerSrc,wmode:'opaque'},conf); }; }, _loadHtmlPlayer:function(player){ var container = document.getElementById(player.params.destId); var video=this._getVideo(player.videoId); if (container && video){ var html = ""); embed.push(""); embed.push(""); embed.push(""); embed.push(""); embed.push(""); embed.push(""); embed.push(""); embed.push(""); embed.push(""); }; return embed.join(""); }, showFakePlayer: function(videoId, contId, width, height, imgPath, onclick) { var container = yq('#' + contId); var fakePlayer = container.find('.fpFakePlayer'); var flashPlayer = container.find('.fpFlashPlayer'); if (fakePlayer.length == 0) { var ctrlBarHeight = 26; var videoHeight = height - ctrlBarHeight; var html = []; html.push("
"); html.push("
"); html.push(""); html.push("
"); html.push("
"); html.push(""); html.push("
"); html.push("
"); html.push("
"); html.push("
"); html.push("
"); html.push("
"); html.push("
"); container.append(yq(html.join(''))); fakePlayer = container.find('.fpFakePlayer'); }; if (flashPlayer.length == 0) { var html = []; html.push("
"); html.push("
"); container.append(yq(html.join(''))); flashPlayer = container.find('.fpFlashPlayer'); }; if(this.displayHtmlPlayer()){ fakePlayer.hide(); flashPlayer.show(); onclick(); } else { container.find('.fpPlayButton').unbind('click').click(onclick); container.find('.fpOpeningImage').attr('src', imgPath); fakePlayer.show(); flashPlayer.hide(); }; }, showFlashPlayer : function(contId, type, videoId, width, height, params) { var container = yq('#' + contId); var flashPlayerId = container.find('.fpFlashPlayer').attr('id'); container.find('.fpFakePlayer').hide(); container.find('.fpFlashPlayer').show(); params.destId = flashPlayerId; this.loadPlayer(type, videoId, width, height, params); }, stopFlashPlayer : function(contId, showFake) { var container = yq('#'+contId); var flashPlayerId = container.find('.fpFlashPlayer').attr('id'); if (flashPlayerId) { this.stopPlayback(flashPlayerId); }; if(showFake){ container.find('.fpFlashPlayer').hide(); container.find('.fpFakePlayer').show(); }; } }; if (!Array.indexOf) { Array.prototype.indexOf = function (obj, start) { for (var i = (start || 0); i < this.length; i++) { if (this[i] == obj) { return i; } } return -1; } } })();