var playerController = function () {
var video = null;
var domain = 'http://i.tmgrup.com.tr';
var iphoneLink = 'UYGULAMAYI İNDİRMEK İÇİN';
var ipadLink = 'UYGULAMAYI İNDİRMEK İÇİN';
var geoBlockadeMsg = 'Şuan izlemek istediğiniz canlı yayın videosu ATV yayın hakları ve hukuki sebepler nedeniyle sadece Türkiye’den izlenebilmektedir.';
var fotomac = "AC97138B-A800-4E53-94E4-D6BF4E6782AB";
var sabah = "50450B66-F39E-4DD8-867B-4D2E15726A5F";
var atv = "0FE2A405-8AFA-4238-B429-E5F96AEC3A5C";
var clienttype = "vast";
var trackList = [];
var isCounter = true;
return {
SetTrackList: function (list) {
this.trackList = list;
},
LoadLivePlayerWithToocast: function () {
if (isZtkBlackout == 'False') {
$.ajax({
type: 'GET',
url: 'http://videotoken.tmgrup.com.tr/webtv/secure?url=http://trkvz-live.ercdn.net/atvhd/atvhd.m3u8&' + Math.floor(Math.random() * 1000000 + 1),
success: function (data) {
if (data != null) {
player.AddLivePlayerWithToken(data.Url);
}
}
});
}
else {
player.AddLivePlayerWithToken('http://trkvz-live.ercdn.net/atvhd_bo/atvhd.m3u8');
}
},
AddLivePlayerWithToken: function (toocastUrl) {
var isMobile = isiPad || isAndroid || isiPhone;
if (isFirefox && !isMobile && FlashDetect.installed != true) {
$("#live").html('
flash player uygulamasını eklemeniz gerekmektedir!
');
}
else {
var ads = [{ offset: "pre", tag: this.GetVast("1") }];
var overlay = this.GetVastObj("5");
if(overlay != null)
ads.push({ offset: overlay.StartTime, tag: overlay.Url, type: "nonlinear" });
jwplayer("live").setup({
playlist: [{
image: "http://i.tmgrup.com.tr/atv/c/i/player_imaj_v2.png",
file: toocastUrl,
title: "Canlı Yayın"
}],
width: '720',
height: '445',
autostart: true,
androidhls: true,
stretching: "exactfit",
primary: 'flash',
events: {
onReady: function () {
AddGemiusStreamCode(true);
//SetGaTrackEvent("Play");
},
onPlay: function () { ComScoreBeacon('02', video, -1); AddGSEvent('playing', this.getPosition()); SetGaTrackEvent("Play"); },
onPause: function () { AddGSEvent('paused', this.getPosition()); SetGaTrackEvent("Pause"); },
onError: function (e) {
jwplayer("live").load([{ file: toocastUrl }]);
jwplayer("live").play(true);
},
onBuffer: function (data) {
if (data.reason == "error") {
jwplayer("live").load([{ file: toocastUrl }]);
jwplayer("live").play(true);
}
},
onAdError: function (e) {
jwplayer().remove();
player.LoadLiveBroadcastForAdError(toocastUrl);
},
onAdPlay: function (event) {
SetComScoreBeacon(event, video, -1);
},
onAdCompanion: function (event) {
ComScoreBeacon('01', video, -1);
}
},
advertising: {
client: clienttype,
skipoffset: 15,
skipmessage: 'xx saniye kaldi',
skiptext: 'reklami gec',
admessage: 'Bu reklam xx saniye sonra bitecek.',
schedule: ads
},
sharing: {
heading: "Videoyu Paylaş",
title: video.Title.replace(/'/g, " ").replace(/&/g, " ").replace(/"/g, " ")
}
});
}
this.AddStatisticCode();
},
LoadLiveBroadcastForAdError: function (toocastUrl) {
jwplayer("live").setup({
playlist: [{
image: "http://i.tmgrup.com.tr/atv/c/i/player_imaj_v2.png",
file: toocastUrl,
title: "Canlı Yayın"
}],
width: '720',
height: '445',
autostart: true,
androidhls: true,
stretching: "exactfit",
primary: 'flash',
events: {
onReady: function () {
AddGemiusStreamCode(true);
//SetGaTrackEvent("Play");
},
onPlay: function () { AddGSEvent('playing', this.getPosition()); SetGaTrackEvent("Play"); },
onPause: function () { AddGSEvent('paused', this.getPosition()); SetGaTrackEvent("Pause"); }
},
sharing: {
heading: "Videoyu Paylaş",
title: video.Title.replace(/'/g, " ").replace(/&/g, " ").replace(/"/g, " ")
}
});
},
LoadPlayerForSeriesWithToocast: function () {
var categoryName = this.GetCategoryName();
var seriesUrl = video.CategoryName == "atv-ana-haber" || video.CategoryName == "hafta-sonu-atv-ana-haber" ? this.GetVideoUrlForNewPlayerSmill() : "http://atv-vod.ercdn.net/{0}/{1}/{2}.smil/playlist.m3u8".replace("{0}", categoryName).replace("{1}", this.GetVideoEpisodeFormat(video.Episode)).replace("{2}", (categoryName + "_" + this.GetVideoEpisodeFormat(video.Episode)));
var seriesUrlMp4 = video.CategoryName == "atv-ana-haber" || video.CategoryName == "hafta-sonu-atv-ana-haber" ? this.GetVideoUrlForNewPlayer() : seriesUrl.replace(".smil/playlist.m3u8", "_0400.mp4");
$.ajax({
type: 'GET',
url: 'http://videotoken.tmgrup.com.tr/webtv/secure?url=' + seriesUrl + '&url2=' + seriesUrlMp4 + '&' + Math.floor(Math.random() * 1000000 + 1),
success: function (data) {
if (data != null) {
player.AddPlayerForSeriesWithToocast(data.Url, data.AlternateUrl);
}
}
});
},
AddPlayerForSeriesWithToocast: function (url, alternateUrl) {
if ((getParameterByName("primary") != null && getParameterByName("primary") != "") &&
(getParameterByName("client") != null && getParameterByName("client") != "") &&
(getParameterByName("url") != null && getParameterByName("url") != "") &&
(getParameterByName("urltype") != null && getParameterByName("urltype") != "")) {
//alert(getParameterByName("primary") + " " + getParameterByName("client") + " " + getParameterByName("advertising") + " " + getParameterByName("advertisingtype"));
player.AdTester(url, alternateUrl);
return;
}
var isMobile = isiPad || isAndroid || isiPhone;
var tempAd = isMobile ? "http://adserver.adtech.de/?advideo/3.0/1418.1/6075857/0//cc=2;vidAS=pre_roll;vidRT=VAST;vidRTV=3.0;vidREG=companion_left:1x1:addyn;cors=yes; " : "http://adserver.adtech.de/?advideo/3.0/1418.1/6075738/0//cc=2;vidAS=pre_roll;vidRT=VAST;vidRTV=3.0;vidREG=companion_left:1x1:addyn;cors=yes; ";
var filterForStats = "&SessionID=" + sessionId + "&StreamGroup=" + video.CategoryName + "&Site=atv&DeviceGroup=" + (isMobile ? "mobil" : "web");
var source = [{ file: url + filterForStats }, { file: alternateUrl + filterForStats }];
var advertising = new Array();
var vast = "";
var related = null;
if (GetParameterByName("r") == null) {
if (video.IsEpisodePreroll && video.IsEpisodePrerollCat) {
advertising.push({ offset: "pre", tag: video.VideoId == "56acd08b-9ff3-40b8-991a-da41de390d43" ? tempAd : this.GetVast("1") });
var overlay = this.GetVastObj("5");
if(overlay != null)
advertising.push({ offset: overlay.StartTime, tag: overlay.Url, type: "nonlinear" });
}
if (video.CategoryName != "atv-ana-haber") {
vast = this.GetVast("2");
if (video.IsEpisodePreroll && video.IsEpisodePrerollCat) {
var postroll = this.GetVastObj("3");
if(postroll != null)
advertising.push({ offset: "post", tag: this.GetVast("3") });
}
related = {
heading: "İlgili Videolar",
file: "/webtv/getrelatedvideosxml/{0}/{1}.xml".replace("{0}", video.CategoryName).replace("{1}", video.VideoId),
dimensions: "200x140"
};
}
}
if (isFirefox && !isMobile && FlashDetect.installed != true) {
$("#live").html("flash player uygulamasını eklemeniz gerekmektedir!
");
}
else {
jwplayer("live").setup({
playlist: [{
image: video.ImageUrl,
sources: source,
tracks: this.trackList
}],
width: '960',
height: '539',
autostart: getParameterByName('t') == null ? true : false,
androidhls: true,
stretching: "exactfit",
primary: isMobile ? 'html5' : 'flash',
events: {
onReady: function () {
var duration = this.getDuration();
AddGemiusStreamCode(false);
//SetGaTrackEvent("Play");
if (getParameterByName('t') != null)
setTimeout(function () { CheckSeekQueryString(); }, 100);
else
setTimeout(function () { CheckSeekQueryString(); }, 3000);
},
onPlay: function () { ComScoreBeacon('03', video, -1); AddGSEvent('playing', this.getPosition()); SetGaTrackEvent("Play"); },
onPause: function () { AddGSEvent('paused', this.getPosition()); SetGaTrackEvent("Pause"); },
onStop: function () { AddGSEvent('stopped', this.getPosition()); SetGaTrackEvent("Stop"); },
onComplete: function () { AddGSEvent('complete', this.getPosition()); SetGaTrackEvent("Complete"); CloseGStream(); player.GetNextVideoHtml(); },
onAdComplete: function () { setTimeout(function () { CheckSeekQueryString(); }, 250) },
onAdSkipped: function () { setTimeout(function () { CheckSeekQueryString(); }, 250) },
onSeek: function () { OnSeekVideo(); },
onTime: function () {
if (video.IsEpisodePreroll && video.IsEpisodePrerollCat && vast != "" && parseInt(this.getPosition()) > 0 && (this.getPosition() * 10) % 6000 == 0) {
jwplayer().playAd(vast);
}
},
onAdError: function (e) {
setTimeout(function () { if (jwplayer("live").getState() != "PLAYING") jwplayer("live").play(); }, 2000);
},
onAdPlay: function (event) {
SetComScoreBeacon(event, video, -1)
},
onAdCompanion: function (event) {
ComScoreBeacon('01', video, -1);
}
},
advertising: {
client: clienttype,
skipoffset: 20,
skipmessage: 'xx saniye kaldi',
skiptext: 'reklami gec',
admessage: 'Bu reklam xx saniye sonra bitecek.',
companiondiv: {
id: "rectangle",
width: 1440,
height: 921
},
schedule: advertising
},
sharing: {
heading: "Videoyu Paylaş",
title: video.Title.replace(/'/g, " ").replace(/&/g, " ").replace(/"/g, " ")
},
related: related,
plugins: {
debug: { levels: "fatal, config, vast_template, vpaid, http_calls" }
}
});
}
this.AddStatisticCode();
},
AdTester: function(url,alternateUrl)
{
var adTestPrimary = getParameterByName("primary");
var adTestClient = getParameterByName("client");
var adTestUrl = getParameterByName("url");
var adTestType = getParameterByName("urltype");
var advertising = new Array();
switch (adTestType) {
case "1":
advertising.push({ offset: "pre", tag: adTestUrl });
break;
case "2":
advertising.push({ offset: 10, tag: adTestUrl});
break;
case "3":
advertising.push({ offset: "post", tag: adTestUrl });
break;
case "5":
advertising.push({ offset: 5, tag: adTestUrl, type: "nonlinear" });
break;
}
var source = [{ file: url }, { file: alternateUrl }];
jwplayer("live").setup({
playlist: [{
image: video.ImageUrl,
sources: source,
tracks: this.trackList
}],
width: '960',
height: '539',
autostart: getParameterByName('t') == null ? true : false,
androidhls: true,
stretching: "exactfit",
primary: adTestPrimary,
events: {
onReady: function () {
var duration = this.getDuration();
AddGemiusStreamCode(false);
},
onPlay: function () { ComScoreBeacon('03', video, -1); AddGSEvent('playing', this.getPosition()); SetGaTrackEvent("Play"); },
onPause: function () { AddGSEvent('paused', this.getPosition()); SetGaTrackEvent("Pause"); },
onStop: function () { AddGSEvent('stopped', this.getPosition()); SetGaTrackEvent("Stop"); },
onComplete: function () { AddGSEvent('complete', this.getPosition()); SetGaTrackEvent("Complete"); CloseGStream(); player.GetNextVideoHtml(); },
onSeek: function () { OnSeekVideo(); },
onAdError: function (e) {
setTimeout(function () { if (jwplayer("live").getState() != "PLAYING") jwplayer("live").play(); }, 2000);
},
onAdPlay: function (event) {
SetComScoreBeacon(event, video, -1)
},
onAdCompanion: function (event) {
ComScoreBeacon('01', video, -1);
}
},
advertising: {
client: adTestClient,
skipoffset: 20,
skipmessage: 'xx saniye kaldi',
skiptext: 'reklami gec',
admessage: 'Bu reklam xx saniye sonra bitecek.',
companiondiv: {
id: "rectangle",
width: 1440,
height: 921
},
schedule: advertising
},
sharing: {
heading: "Videoyu Paylaş",
title: video.Title.replace(/'/g, " ").replace(/&/g, " ").replace(/"/g, " ")
},
plugins: {
debug: { levels: "fatal, config, vast_template, vpaid, http_calls" }
}
});
this.AddStatisticCode();
},
AddPlayerForSeries: function () {
var bits = this.GetBitratesArr();
if (video != null) {
if (video.IsFragmanForEpisode) {
this.AddPlayer();
return;
}
if (bits.length < 1)
AddVideoCoverImage();
else
this.LoadPlayerForSeriesWithToocast();
}
},
AddPlayer: function () {
var isMobile = isiPad || isAndroid || isiPhone;
var tempAd = isMobile ? "http://adserver.adtech.de/?advideo/3.0/1418.1/6075857/0//cc=2;vidAS=pre_roll;vidRT=VAST;vidRTV=3.0;vidREG=companion_left:1x1:addyn;cors=yes; " : "http://adserver.adtech.de/?advideo/3.0/1418.1/6075738/0//cc=2;vidAS=pre_roll;vidRT=VAST;vidRTV=3.0;vidREG=companion_left:1x1:addyn;cors=yes; ";
if (video.SecureVideoUrl == "" && !video.IsReference)
AddVideoCoverImage();
else {
var _videoUrl = video.IsReference ? video.ReferenceVideoUrl : ("http://video02.atv.com.tr/" + (video.VideoUrl.indexOf('.flv') > -1 ? video.VideoUrl : (video.VideoUrl + ".mp4")));
_videoUrl = _videoUrl.replace("http://i.atv.com.tr/", "");
var width = '960';
var height = '539';
if (typeof isembed != 'undefined' && isembed) {
width = '100%';
height = '100%';
}
if (typeof embedshowads == 'undefined' || (typeof embedshowads == 'boolean' && embedshowads)) {
//var playerInstance = jwplayer("live");
//playerInstance.setup({
if (isFirefox && !isMobile && FlashDetect.installed != true) {
$("#live").html("flash player uygulamasını eklemeniz gerekmektedir!
");
}
else {
var advertising = new Array();
if (video.IsPreroll && video.IsPrerollCat)
advertising.push({ offset: "pre", tag: video.VideoId == "0bf3e940-27de-4eb1-8dca-ddfe8104475d" ? tempAd : this.GetVast("1") });
jwplayer("live").setup({
file: _videoUrl,
image: video.ImageUrl,
tracks: this.trackList,
width: width,
height: height,
autostart: true,
androidhls: true,
stretching: "exactfit",
//startparam: 'start',
primary: isMobile ? 'html5' : 'flash',
events: {
onReady: function () {
var duration = this.getDuration();
AddGemiusStreamCode(false);
},
onPlay: function () { ComScoreBeacon('02', video, -1); AddGSEvent('playing', this.getPosition()); },
onPause: function () { AddGSEvent('paused', this.getPosition()); },
onStop: function () { AddGSEvent('stopped', this.getPosition()); },
onComplete: function () { AddGSEvent('complete', this.getPosition()); CloseGStream(); player.GetNextVideoHtml(); },
onAdError: function (e) {
setTimeout(function () { if (jwplayer("live").getState() != "PLAYING") jwplayer("live").play(); }, 2000);
},
onAdPlay: function (event) {
SetComScoreBeacon(event, video, -1)
},
onAdCompanion: function (event) {
ComScoreBeacon('01', video, -1);
},
onTime: function () { }
},
advertising: {
client: clienttype,
skipoffset: 15,
skipmessage: 'xx saniye kaldi',
skiptext: 'reklami gec',
admessage: 'Bu reklam xx saniye sonra bitecek.',
companiondiv: {
id: "rectangle",
width: 1440,
height: 921
},
schedule: advertising
},
sharing: {
heading: "Videoyu Paylaş",
title: video.Title.replace(/'/g, " ").replace(/&/g, " ").replace(/"/g, " ")
},
related: {
heading: "İlgili Videolar",
file: "/webtv/getrelatedvideosxml/{0}/{1}.xml".replace("{0}", video.CategoryName).replace("{1}", video.VideoId),
dimensions: "200x140"
},
plugins: {
debug: { levels: "fatal, config, vast_template, vpaid, http_calls" }
}
});
}
}
else {
if (isFirefox && !isMobile && FlashDetect.installed != true) {
$("#live").html("flash player uygulamasını eklemeniz gerekmektedir!
");
}
else {
jwplayer("live").setup({
file: _videoUrl,
image: video.ImageUrl,
tracks: this.trackList,
width: width,
height: height,
autostart: true,
androidhls: true,
stretching: "exactfit",
//startparam: 'start',
primary: isMobile ? 'html5' : 'flash',
events: {
onReady: function () {
var duration = this.getDuration();
AddGemiusStreamCode(false);
},
onPlay: function () { ComScoreBeacon('02', video, -1); AddGSEvent('playing', this.getPosition()); },
onPause: function () { AddGSEvent('paused', this.getPosition()); },
onStop: function () { AddGSEvent('stopped', this.getPosition()); },
onComplete: function () { AddGSEvent('complete', this.getPosition()); CloseGStream(); },
onAdError: function (e) {
setTimeout(function () { if (jwplayer("live").getState() != "PLAYING") jwplayer("live").play(); }, 2000);
},
onAdPlay: function (event) {
SetComScoreBeacon(event, video, -1)
},
onAdCompanion: function (event) {
ComScoreBeacon('01', video, -1);
}
},
sharing: {
heading: "Videoyu Paylaş",
title: video.Title.replace(/'/g, " ").replace(/&/g, " ").replace(/"/g, " ")
},
related: {
heading: "İlgili Videolar",
file: "/webtv/getrelatedvideosxml/{0}/{1}.xml".replace("{0}", video.CategoryName).replace("{1}", video.VideoId),
dimensions: "200x140"
},
plugins: {
debug: { levels: "fatal, config, http_calls" }
}
});
}
}
this.AddStatisticCode();
}
},
AddPlayerForIphone: function (pageName) {
switch (pageName) {
case "Series":
var bits = eval(video.BitrateVideoUrls);
if (bits != undefined && bits.length > 0) {
this.LoadPlayerForSeriesWithToocast();
}
else {
AddVideoCoverImage();
}
this.LoadPlayerForSeriesWithToocast();
break;
case "VideoDetail":
case "Fragment":
case "SpecialVideo":
this.AddPlayer();
break;
}
},
GetVideoUrlForNewPlayer: function () {
return this.GetVideoUrlForNP("http://atv-vod.ercdn.net/atv_haber/{2}/{0}/{1}_0400.mp4")
},
GetVideoUrlForNewPlayerSmill: function () {
return this.GetVideoUrlForNP("http://atv-vod.ercdn.net/atv_haber/{2}/{0}/{1}.smil/playlist.m3u8");
},
GetVideoUrlForNP: function (url) {
var date = new Date(parseInt(video.CreatedDate.substr(6)));
var month = video.BaseVideoUrl.substring(14, 16);
var returnUrl = url.replace("{1}", video.BaseVideoUrl.replace("_0400", ""))
.replace("{2}", date.getFullYear())
.replace("{0}", month);
return returnUrl;
},
GetVideoEpisodeFormat: function (episode) {
var index = String(episode).length;
var e = "";
while (index < (video.CategoryName == "kim-milyoner-olmak-ister" || video.CategoryName == "zahide-ile-yetis-hayata" ? 4 : 3)) {
e += "0";
index++;
}
return e + episode;
},
GetBitratesArr: function () {
var arr = new Array();
if (video != null) {
var bits = eval(video.BitrateVideoUrls);
if (bits != undefined)
for (var i = 0; i < bits.length; i++) {
var bit = bits[i];
var rate = bit.BitRate != null ? bit.BitRate : parseInt(bit.AlternateText)
var item = new Object();
var url = "mp4:" + (bit.AmazonPath != null ? bit.AmazonPath : bit.Path).replace(".mp4", "");
item.url = (video.CategoryName == "atv-ana-haber" ? "mp4:" + video.SecureVideoUrl : url);
item.width = rate;
item.bitrate = rate;
if (i == 0) {
item.isDefault = true;
item.normal = true;
}
arr.push(item);
}
}
return arr;
},
GetCategoryName: function () {
switch (video.CategoryName) {
case "alemin-kirali": return "alemin_krali";
case "kim-milyoner-olmak-ister": return "milyoner";
case "hafta-sonu-atv-ana-haber": return "atv_haber";
//case "zahide-ile-yetis-hayata": return "yetis_hayata";
}
return video.CategoryName.replace(/-/g, "_");
},
GetVast: function (typeId) {
var tar = '';
var partParameter = GetParameterByName("l"); /* Dizilerde birinci part haricinde reklam gösterilmez */
if ((partParameter == "" || partParameter == null || partParameter == "1") || (partParameter != "1" && typeId != "1")) {
if (video.Vasts != null) {
var vasts = eval(video.Vasts);
if (vasts != undefined)
for (var i = 0; i < vasts.length; i++) {
var vast = vasts[i];
if (((vast.Section == "FRAGMAN" && video.ArticleType == 11) ||
(vast.Section == "OZELVIDEO" && video.ArticleType == 12) ||
(vast.Section == "BOLUM" && video.ArticleType == 10) ||
(vast.Section == "BOLUM" && video.ArticleType == 16)) &&
vast.TypeId == typeId) {
tar = vast.Url;
break;
}
}
}
}
return tar;
},
GetVastObj: function (typeId) {
var vastObj = null;
if (video.Vasts != null) {
var vasts = eval(video.Vasts);
if (vasts != undefined)
for (var i = 0; i < vasts.length; i++) {
var vast = vasts[i];
if (((vast.Section == "FRAGMAN" && video.ArticleType == 11) ||
(vast.Section == "OZELVIDEO" && video.ArticleType == 12) ||
(vast.Section == "BOLUM" && video.ArticleType == 10) ||
(vast.Section == "BOLUM" && video.ArticleType == 16)) &&
vast.TypeId == typeId) {
vastObj = vast;
break;
}
}
}
return vastObj;
},
GetVastArr: function () {
var partParameter = GetParameterByName("l"); /* Dizilerde birinci part haricinde reklam gösterilmez */
var arr = new Array();
if (partParameter == "" || partParameter == null || partParameter == "1") {
if (video != null && video.Vasts != null) {
var vasts = eval(video.Vasts);
if (vasts != undefined) {
var index = -1;
var isBolumVast = false;
for (var i = 0; i < vasts.length; i++) {
var vast = vasts[i];
if (vast.Section == "FRAGMAN" || vast.Section == "OZELVIDEO") continue;
var vastType = (vast.TypeId != "" && vast.TypeId != 0) ? String(vast.TypeId) : vast.Name;
var target = ((vast.Target != "" && vast.Target != null) ? vast.Target : vast.Url);
index = vastType == "1" && vast.Section == "" ? i : index;
var item = new Object();
if (vast.Section == "BOLUM" && vastType == "1") {
isBolumVast = true;
target = vast.Url;
}
item.position = this.GetVastTypeName(vastType);
item.tag = target;
if (vastType == "2" || vastType == "5") {
var startTimeMinute = "10";
var startTimeSecond = "00";
if (vast.StartTime != 0) {
startTimeMinute = parseInt(vast.StartTime / 60);
startTimeSecond = vast.StartTime % 60;
startTimeMinute = startTimeMinute < 10 ? ("0" + startTimeMinute.toString()) : startTimeMinute;
startTimeSecond = startTimeSecond < 10 ? ("0" + startTimeSecond.toString()) : startTimeSecond;
}
item.startTime = "00:{0}:{1}".replace("{0}", startTimeMinute).replace("{1}", startTimeSecond);
}
if (vastType == "2" || vastType == "3" || vastType == "5")
item.loadOnDemand = true;
if (vastType == "5") {
item.width = 640;
item.height = 100;
item.duration = "60";
item.acceptedAdTypes = ["image"];
item.overlay = true;
item.position = "auto:bottom";
}
arr.push(item);
}
if (index > -1 && isBolumVast)
arr.splice(index, 1);
}
}
}
return arr;
},
GetVastTypeName: function (type) {
switch (type) {
case "1": return "pre-roll";
case "2": return "mid-roll";
case "3": return "post-roll";
case "5": return "overlay";
}
return "pre-roll";
},
Remove: function (val) {
$(val).remove();
},
AddIPhoneLink: function () {
player.AddAndroidPlayer();
},
AddIPadLink: function () {
player.AddAndroidPlayer();
},
AddAndroidPlayer: function () {
jwplayer("live").setup({
playlist: [{
file: 'http://trkvz-m.ercdn.net/trkvz-temp/atvhdm.m3u8',
image: 'http://i.tmgrup.com.tr/atv/c/i/player_imaj_v2.png',
title: 'Canlı Yayın'
}],
autostart: true,
startparam: 'start',
primary: 'html5',
width: '100%',
aspectratio: "16:9",
androidhls: true,
events: {
onComplete: function () { },
onStop: function () { },
onReady: function () {
AddGemiusStreamCode(true);
//SetGaTrackEvent("Play");
},
onPlay: function () { ComScoreBeacon('02', video, -1); AddGSEvent('playing', this.getPosition()); SetGaTrackEvent("Play"); },
onPause: function () { AddGSEvent('paused', this.getPosition()); SetGaTrackEvent("Pause"); },
onAdPlay: function (event) {
SetComScoreBeacon(event, video, -1)
},
onAdCompanion: function (event) {
ComScoreBeacon('01', video, -1);
}
},
advertising: {
client: clienttype,
skipoffset: 15,
skipmessage: 'xx saniye kaldi',
skiptext: 'reklami gec',
admessage: 'Bu reklam xx saniye sonra bitecek.',
schedule: {
myAds: {
offset: "pre",
tag: this.GetVast("1")
}
}
}
});
},
AddGeoBlockade: function () {
$("#live").html(geoBlockadeMsg);
},
AddStatisticCode: function () {
if (video != null)
$("#divStat").html("");
},
SetVideo: function (v) {
video = v;
},
GetClientType: function () {
return clienttype;
},
GetRelatedVideos: function () {
var relatedArr = new Array();
if (relatedVideos != null) {
for (var i = 0; i < relatedVideos.length; i++) {
var obj = relatedVideos[i];
var episode = obj.ArticleType == 10 || obj.ArticleType == 11 ? obj.Url.substring(obj.Url.lastIndexOf('/') + 1, obj.Url.indexOf('?')) : "";
var item = new Object();
item.label = obj.Title.replace(/'/g, " ").replace(/&/g, " ").replace(/"/g, " ") + " " + episode + (obj.ArticleType == 10 || obj.ArticleType == 11 ? (obj.ArticleType == 11 ? ". Fragman" : ". Bölüm") : "");
item.imageUrl = obj.ImageUrl;
item.index = i;
item.url = obj.Url;
relatedArr.push(item);
}
}
return relatedArr;
},
GetNextVideoHtml: function () {
if (relatedVideos != null && relatedVideos[0] != null && $("#divNextVideo").length > 0) {
var nextVideo = relatedVideos[Math.floor(Math.random() * relatedVideos.length)];
var title = (nextVideo.ArticleType == 10 || nextVideo.ArticleType == 11 ? (nextVideo.Episode + (nextVideo.ArticleType == 11 ? ". Bölüm Fragmanı" : ". Bölüm")) : nextVideo.Title.replace(/'/g, " ").replace(/&/g, " ").replace(/"/g, " "));
$("#nextVideoTitle").text(title);
$("#nextVideoLink").attr("href", nextVideo.Url);
$("#divNextVideo").show();
$('#mCount').timer(function () {
$("#aCounter").text("Bir sonraki videoya geçiliyor...");
window.location.href = nextVideo.Url;
});
$("#aCounter").on("click", function () {
if ($('#mCount').attr("timer") != null && parseInt($('#mCount').attr("timer")) > 0) {
$(this).toggleClass("pause");
isCounter = !isCounter;
$('#mCount').attr("paused", isCounter ? "0" : "1");
}
});
}
}
}
}
var player = new playerController();
var isGeoblockade = false;
var pageName = "";
var video = null;
var talkname = null;
var adid = null;
var bnid = null;
var relatedVideos = null;
var isFirefox = navigator.userAgent.indexOf("Firefox") > -1;
var isiPad = navigator.userAgent.match(/(iPad)/) != null ? true : false;
var isiPhone = navigator.userAgent.match(/(iPhone)/) != null ? true : false;
var isAndroid = navigator.userAgent.match(/Android/i) != null ? true : false;
var isSafari = /^((?!chrome).)*safari/i.test(navigator.userAgent);
var isOtherMobile = navigator.userAgent.match(/webOS|BlackBerry|BB|Mobile|Nokia|IEMobile|Opera Mini|Windows Phone/i) != null ? true : false;
var isSurvey = ((typeof isembed != 'undefined' && isembed) || ((typeof embedshowads != 'undefined' && !embedshowads))) ? false : true; //burası true ise video da anket yayınlanır false ise video da anket yayınlanmaz
var isAddPlayer = false;
var timeout = 60000 * 3;
var t = "";
var IDENTIFIER = '';
var HITCOLLECTOR = "http://str.hit.gemius.pl";
var PREFIX = "str";
var playerId = "player_" + Math.round(Math.random() * 1000000);
var materialIdentifier = '';
var treeId = [];
var additionalPackage = [];
var customPackage = [];
var surveyList = [];
var totalTime = 1;
$(function () {
LoadPlayer();
});
function LoadPlayer() {
if (video != null && video.IsBaseVideo) {
AddVideoCoverImage();
SetVideoSize(960, 539);
$('.webTvDetay .txt').css('width', 'auto');
$('.webTvDetay .txt .left').css('width', 'auto');
}
else {
if (isSurvey)
ShowSurvey();
else {
$("#PlayerSize").show();
IDENTIFIER = 'csrrC8Li5LoUFbNYBCkUe9U5XkDNbAbHe2iIzwrnBDz.V7';
materialIdentifier = video.VideoId;
customPackage = [{ name: 'Category', value: (video.CategoryName == "" ? "AtvWebTv" : video.CategoryName) }];
player.SetVideo(video);
if (typeof trackList != 'undefined') {
player.SetTrackList(trackList);
}
if (pageName == "LiveBroadcast" || pageName == "LiveBroadcastHd")
ShowPageItem();
//CheckGeoblockade();
else {
if ((video.IsGeoBlockedCategory || video.IsGeoBlocked) && video.ArticleType == 10)
CheckGeoIp();
else
ShowPageItem();
}
}
}
}
function AddVideoCoverImage() {
if (video.ImageUrl != null)
$("#live").html(''.replace("{Path}", video.ImageUrl).replace("{Title}", video.CategoryName));
$("#PlayerSize").hide();
}
function CheckGeoblockade() {
clearTimeout(t);
$.ajaxSettings.cache = false;
$.getJSON("/webtv/CheckGeoBlockade?cctmd=1m", null, function (data) {
if (isGeoblockade != data.isBlockade || !isAddPlayer) {
isGeoblockade = data.isBlockade;
ShowPageItem();
}
if ((pageName == "LiveBroadcast" || pageName == "LiveBroadcastHd") && !isiPad && !isiPhone)
t = setTimeout('CheckGeoblockade()', timeout);
});
}
function CheckGeoIp() {
$.ajaxSettings.cache = false;
$.getJSON("/webtv/checkGeoIp?cctmd=nc", null, function (data) {
isGeoblockade = data.isBlockade;
ShowPageItem();
});
}
function ShowPageItem() {
if (isiPad || isiPhone || isAndroid || isOtherMobile )
ShowPlayerForIphoneIpad();
else
ShowPlayer();
isAddPlayer = true;
}
function ShowPlayer() {
if (isGeoblockade)
player.AddGeoBlockade();
else {
switch (pageName) {
case "LiveBroadcast": player.LoadLivePlayerWithToocast(); break;
case "LiveBroadcastHd": player.AddPlayerForLiveBroadcastHd(); break;
case "Series": player.AddPlayerForSeries(); SetChangeVideoSize(); ChangeVideoSize(); SetVideoPartArr(); CheckBookmarkAndStart(); break;
case "VideoDetail":
case "Fragment":
case "SpecialVideo": player.AddPlayer(); SetChangeVideoSize(); ChangeVideoSize(); break;
}
}
}
function ShowPlayerForIphoneIpad() {
if (pageName == "LiveBroadcast") {
if (isiPad)
player.AddIPadLink();
else if (isiPhone)
player.AddIPhoneLink();
else
player.AddAndroidPlayer();
}
else {
if (isGeoblockade)
player.AddGeoBlockade();
else
player.AddPlayerForIphone(pageName);
}
}
function ShowLiveBroadcastNoApp() {
player.AddAndroidPlayer();
}
function ShowSurvey() {
GetSurveyList();
var survey = null;
if (surveyList.length > 0) {
if (surveyCookie1.items().length == 0 && surveyCookie2.items().length == 0) {
survey = surveyList[Math.floor(Math.random() * surveyList.length)];
}
if (survey != null) {
$("#live").html(SurveyTemplate(survey));
SetSurveyEvents(survey);
return;
}
}
isSurvey = false;
LoadPlayer();
}
var currentPartPoint = 0;
var currentPartNo = 1;
var nextPoint = 0;
var prevPoint = 0;
var partLength = 0;
var videoPartArr = new Array();
var bookmarkTimer = null;
var bookmarkTimeOut = 2000;
function SetVideoPartArr() {
partLength = $("#videoPart li").length || 0;
if (partLength > 0) {
$("#videoPart li").each(function () {
var p = $(this).attr("data-point");
videoPartArr.push(parseInt(p));
});
}
}
function CheckSeekQueryString() {
var query = getParameterByName("t");
var fullduration = parseInt(jwplayer().getDuration(), 10);
if (fullduration > 40 || (fullduration == -1 && query != null)) {
var li = getParameterByName("l");
if (li != "" && li != null) {
currentPartNo = parseInt(li);
$("#videoPart li").removeClass("current");
$("#part_" + currentPartNo).addClass("current");
}
if (query != "" && query != null) {
jwplayer().seek(query);
currentPartPoint = parseInt(query);
if (currentPartNo < videoPartArr.length) {
bookmarkTimer = setTimeout("CheckNextPart()", bookmarkTimeOut);
nextPoint = parseInt($("#part_" + (currentPartNo + 1)).attr("data-point"));
}
if (currentPartNo > 1)
prevPoint = parseInt($("#part_" + (currentPartNo - 1)).attr("data-point"));
}
}
}
function CheckBookmarkAndStart() {
var isPartQuery = GetParameterByName("t");
if ((isPartQuery == "" || isPartQuery == null) && partLength > 0) {
$("#part_" + currentPartNo).addClass("current");
nextPoint = parseInt($("#part_" + (currentPartNo + 1)).attr("data-point"));
bookmarkTimer = setTimeout("CheckNextPart()", bookmarkTimeOut);
}
}
function OnSeekVideo() {
var currentTime = parseInt(jwplayer().getPosition());
if (currentTime > 10 && partLength > 0) {
clearTimeout(bookmarkTimer);
currentPartNo = Math.floor(currentTime / videoPartArr[1]) + 1;
$("#videoPart li").removeClass("current");
$("#part_" + currentPartNo).addClass("current");
if (currentPartNo < partLength) {
bookmarkTimer = setTimeout("CheckNextPart()", bookmarkTimeOut);
nextPoint = parseInt($("#part_" + (currentPartNo + 1)).attr("data-point"));
}
if (currentPartNo > 1)
prevPoint = parseInt($("#part_" + (currentPartNo - 1)).attr("data-point"));
}
}
function CheckNextPart() {
var currentTime = parseInt(jwplayer().getPosition());
var tempPartNo = Math.floor(currentTime / videoPartArr[1]) + 1;
if (nextPoint <= currentTime) {
SetVideoSeek(window.location.pathname, currentTime/*nextPoint*/, (tempPartNo));
return;
}
if (currentTime > prevPoint && currentTime < (tempPartNo - 3)) {
SetVideoSeek(window.location.pathname, currentTime/*prevPoint*/, tempPartNo - 1);
return;
}
bookmarkTimer = setTimeout("CheckNextPart()", bookmarkTimeOut);
}
function SetVideoSeek(url, point, id) {
window.location.href = url + (url.indexOf('?') > -1 ? '&t=' : '?t=') + point + '&l=' + id + '&id=' + getParameterByName("id");
}
function GetParameterByName(name) {
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
function AddGemiusStreamCode(isLive) {
totalTime = isLive ? 1 : parseInt(jwplayer().getDuration(), 10);
gemiusStream.newStream(playerId, materialIdentifier, totalTime, customPackage, additionalPackage, IDENTIFIER, HITCOLLECTOR, treeId);
//AddGSEvent('playing', 0);
}
function AddGSEvent(action, time) {
gemiusStream.event(playerId, materialIdentifier, time, action);
}
function CloseGStream() {
gemiusStream.closeStream(playerId, materialIdentifier, 10);
}
function NavigateToUrl(url) {
window.location.href = url;
}
var isVideoSize = true;
var detayH;
var $btn;
function SetChangeVideoSize() {
$('body').addClass('w4');
}
function ChangeVideoSize() {
if (isVideoSize) {
$('.colB').css('margin-top', 0);
$('body').addClass('w4');
$('body').removeClass('w2').delay(400).queue(function (CallBack) {
SetVideoSize(960, 539);
$('.btnResize').css('background-image', 'url("http://i.tmgrup.com.tr/atv/c/i/btnDaralt.png")');
$('.btnResize').css('margin-top', 10);
$('.btnResize').css('right', 'auto');
$('.webTvDetay .txt').css('width', 'auto');
$('.webTvDetay .txt .left').css('width', 'auto');
$('.player').css('width', 'auto');
isVideoSize = false;
CallBack();
});
} else {
SetVideoSize(640, 400);
$('.colB').css('margin-top', -detayH);
$('.btnResize').css('background-image', 'url("http://i.tmgrup.com.tr/atv/c/i/btnGenislet.png")');
$btn.find('span').html('videoyu genişlet');
$('.btnResize').css('margin-top', 5);
$('.btnResize').css('right', -12);
$('.player').css('width', 640);
$('.webTvDetay .txt .left').css('width', 570);
$('.webTvDetay .txt').css('width', 620);
isVideoSize = true;
$('body').addClass('w2');
}
}
function SetVideoSize(w, h) {
if (typeof isembed != 'undefined' && isembed == true)
return;
$("#live").width(w);
$("#live").height(h);
if ($("#live img").length > 0) {
$("#live img").width(w);
$("#live img").height(h);
}
if ($("#live_wrapper").length > 0) {
$("#live_wrapper").width(w);
$("#live_wrapper").height(h);
}
}
function SurveyTemplate(survey) {
var html = "";
html = html.replace('{question}', survey.question).replace('{surveyId}', survey.id);
var options = '';
for (var i = 0; i < survey.optionList.length; i++) {
options += OptionTemplate().replace('{optionValue}', survey.optionList[i].value).replace('{optionText}', survey.optionList[i].name);
}
html = html.replace('{options}', options);
return html;
}
function OptionTemplate() {
return "{optionText}";
}
function SetSurveyEvents(survey) {
$(".surveyApp li").live("click", function () {
var selVal = "0";
if ($(this).val() == 1) {
selVal = "1";
}
if (survey.id == "beb")
surveyCookie1.add(survey.id + "=" + selVal);
else if (survey.id == "araba")
surveyCookie2.add(survey.id + "=" + selVal);
$("#live").html('');
isSurvey = false;
var urlAdtech = "https://secserv.adtech.de/bind?ckey1=" + survey.id + ";cvalue1=" + selVal + ";expiresDays=90;adct=image/gif;misc=123";
$("#divStat").append("");
LoadPlayer();
});
}
function Survey() {
this.question = "";
this.optionList = [];
this.id = "";
}
function GetSurveyList() {
var survey2 = new Survey();
survey2.question = "0-3 yaş arası bebeğiniz var mı?";
survey2.optionList = [{ name: 'Evet', value: 1 },
{ name: 'Hayır', value: 0 }
];
survey2.id = "beb";
//surveyList.push(survey2);
}
/* cookie işlemleri */
var cookieList = function (cookieName) {
var cookie = $.cookie(cookieName);
var items = cookie ? cookie.split(/,/) : new Array();
return {
"add": function (val) {
items.push(String(val));
$.cookie(cookieName, items.join(','), { expires: 45, path: "/" });
},
"remove": function (val) {
indx = items.indexOf(String(val));
if (indx != -1) items.splice(indx, 1);
$.cookie(cookieName, items.join(','), { expires: 30 });
},
"clear": function () {
items = new Array();
$.cookie(cookieName, items);
},
"items": function () {
return items;
},
"getlastitem": function () {
return items[items.length - 1];
},
"find": function (val) {
indxs = items.indexOf(String(val));
if (indxs != -1) return true;
return false;
}
}
}
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (elt /*, from*/) {
var len = this.length;
var from = Number(arguments[1]) || 0;
from = (from < 0)
? Math.ceil(from)
: Math.floor(from);
if (from < 0)
from += len;
for (; from < len; from++) {
if (from in this &&
this[from] === elt)
return from;
}
return -1;
};
}
$.fn.extend({
timer: function (callback) {
var element = $(this);
timerTimeOut = setInterval(function () {
if ($(element).attr('paused') != null && $(element).attr('paused') != '1') {
var timeOut = parseInt($(element).attr("timer"));
timeOut--;
$(element).text(timeOut);
$(element).attr('timer', timeOut);
if (timeOut <= 0) {
clearInterval(timerTimeOut);
timerTimeOut = null;
callback();
}
}
}, 1000);
}
});
var surveyCookie1 = new cookieList("beb");
var surveyCookie2 = new cookieList("araba");
/* cookie işlemleri son */
function ShowCompanion() {
if ($("#pageskin_atv_diziler a img").length > 0) {
// $("#pageskin_atv_diziler a img").width(1982);
// $("#pageskin_atv_diziler a img").height(1000);
}
}
//function HideCompanion() {
// if ($("#pageskin_atv_diziler").length > 0)
// $("#pageskin_atv_diziler").show();
// $(".headerC").removeAttr("style");
// $(".banner980").css("z-index", "0");
// if ($("#companion").length > 0)
// $("#companion").css("z-index", "-1");
//}
function SetGaTrackEvent(event) {
// _gaq.push(['_trackEvent', 'Videos', event, (video.CategoryName + "_" + (video.ArticleType == 11 ? "fragman" : "bölüm"))]);
}
function ComScoreBeacon(tagTypeId, video, currentPart) {
try {
var page = document.location.href;
var referrer = document.referrer;
var title = document.title;
if (typeof (page) == "undefined" || page == "null")
page = "http://www.atv.com.tr";
if (typeof (referrer) == "undefined" || referrer == "null")
referrer = "";
if (typeof (title) == "undefined" || title == "null")
title = "";
if (page != null && page.length > 512)
page = page.substr(0, 512);
if (referrer.length > 512)
referrer = referrer.substr(0, 512);
var totalPart = typeof (videoBookMark) != 'undefined' ? videoBookMark : 6;
var url = (new Array(
page.indexOf("https:") == 0 ? "https://sb" : "http://b",
".scorecardresearch.com/p",
"?c1=", '1',
"&c2=", '6331775',
"&c3=", '10',
"&c4=", '',
"&c5=", encodeURIComponent(tagTypeId),
"&c6=", encodeURIComponent('[' + video.CategoryName + ']--' + 'S01E' + video.Episode),
"&c10=", currentPart + '-' + totalPart,
"&c7=", encodeURIComponent(page),
"&c8=", encodeURIComponent(title),
"&c9=", encodeURIComponent(referrer),
"&rn=", Math.random(),
"&cv=2.0"
)).join("");
if (url.length > 2080)
url = url.substr(0, 2080);
$('body').append('');
return url;
}
catch (e) {
//console.log(e);
}
}
function SetComScoreBeacon(event, video, currentPart) {
if (currentPart == -1) {
try {
currentPart = getParameterByName('l');
if (currentPart == '' || parseInt(currentPart) < 1)
currentPart = 1;
}
catch (exception) {
currentPart = 1;
}
}
var tagTypeId = '01';
if (event.tag.indexOf('pre_roll') > -1 || event.tag.indexOf('preroll') > -1)
tagTypeId = '09';
else if (event.tag.indexOf('post_roll') > -1 || event.tag.indexOf('postroll') > -1)
tagTypeId = '10';
else if (event.tag.indexOf('mid_roll') > -1 || event.tag.indexOf('midroll') > -1)
tagTypeId = '11';
ComScoreBeacon(tagTypeId, video, currentPart);
}
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^]*)"),
results = regex.exec(location.search);
return results === null ? null : decodeURIComponent(results[1].replace(/\+/g, " "));
}