var VodPlayList = {};
//동영상 플레이어 테그 삽입
function fnVodPlay(vod_id, ref, options) {
if (vod_id) {
//뉴스용 플레이어입니다. Jucode의 앞 두자리로 비교해서 분기문 처리 해서 방송, 제보쪽 작업 진행하셔야 할듯...
// GetVod는 news도메인에 있는 뉴스DB를 조회하게 되니 이쪽으로 id넘겨봐야 데이타 없어요.
if (vod_id.substring(0, 2) == "NV") { fnVodPlayNews(vod_id, ref, options); }
// WIZARD에서 동영상 보기
if (vod_id.substring(0, 2) == "VO") { fnVodPlayWizard(vod_id, ref, options); }
}
}
function fnVodPlayNews(vod_id, ref, options) {
// 기본 옵션
var default_options = { width: 480, height: 299, image: "", userid: "", ad_presn: "", ad_postsn: "", ad_vt: "N" };
// param으로 들어온 옵션을 기본 옵션과 병합
var opts = jQuery.extend({}, default_options, options);
var _vod_memid = "";
try { _vod_memid = getCookieA("MemArray","MemID"); } catch(e) {}
var device_info = "W"
if (typeof (mobile_device_detect) == "function") { device_info = mobile_device_detect(); }
if(navigator.userAgent.toLowerCase().indexOf("iphone") > -1)
{device_info = "P"}
jQuery.getJSON("http://article.joins.com/news/jtbc/get_vod_jsondata.asp?callback=?&vodid=" + vod_id +"&m="+ device_info, function (data) {
if (data != null && data != {}) {
//var vod_logger = "http://counter.jtbc.joins.com/bin/ArticleCounterLogger.dll?Total_ID=" + vod_id + "&Ctg_ID=00&memid="+ _vod_memid +"&gubun="+ device_info +"&cloc=&ref="+ ((typeof(ref) != "undefined") ? ref : "") +"&svc=T";
//jQuery("body").append("");
var vodInfo = data.vod_info;
var params = {};
params.width = opts.width;
params.height = opts.height;
params.flashplayer = "http://fs.jtbc.joins.com/common/ctl/player/player.swf";
params.skin = "http://fs.jtbc.joins.com/common/ctl/player/glow.zip";
/* option으로 이미지정보가 들어오는 경우 동영상 썸네일 이미지를 그것으로 대체, 기본은 동영상에 연결된 섬네일로 보임 */
if (opts.image != "") {
params.image = opts.image;
} else {
params.image = vodInfo.img_url;
}
if (!vodInfo.file_url) { return; /* 동영상 파일정보 없음 */ }
if (typeof(vodInfo.file_url) != "undefined" && vodInfo.file_url.indexOf("rtmp://") > -1) {
var arr_file_url = vodInfo.file_url.split("&file=");
params.provider = "rtmp";
params.streamer = escape(arr_file_url[0]);
params.file = escape(arr_file_url[1]);
} else {
params.file = vodInfo.file_url;
params.provider = vodInfo.file_url.substring(0, 4);
}
var _vod_packcode = "", _vod_pay = "N", _vod_paydiv = "00", _vod_payamount = "0";
if (jQuery("#div_" + vod_id).length > 0) {
if (device_info == "W") {
var so = new SWFObject(params.flashplayer, 'player_' + vod_id, params.width, params.height, '9', '#000000');
so.addParam('allowfullscreen', 'true');
so.addParam('allowscriptaccess', 'always');
so.addParam('wmode', 'opaque');
so.addVariable('stretching', 'fill');
// so.addVariable('icons','false');
so.addVariable('type', params.provider); // Protocol(고정)
so.addVariable('streamer', params.streamer); // VOD URL Path
so.addVariable('file', params.file); // VOD URL 중 파일명
so.addVariable('image', params.image); // Thumbnail Image URL - VOD에 따라 변경
so.addVariable('skin', params.skin);
/*if (opts.ad_presn != "" || opts.ad_postsn != "") {
// 광고 연결
var ad_url = 'http://dgate.jtbc.joins.com/xc.aspx?presn=' + opts.ad_presn + '&postsn=' + opts.ad_postsn + '&vt=' + opts.ad_vt;
so.addVariable('plugins', 'adtvideo'); // AD Plugin(고정)
so.addVariable('adtvideo.config', ad_url); // AD 정보 XML 파일 URL
if (typeof (console) == "object") { console.log("load ad : " + ad_url); }
}*/
so.addVariable('controlbar', 'bottom');
so.write("div_" + vod_id);
if (jQuery("#player_" + vod_id).length > 0) {
VodPlayList[vod_id] = "false";
// Play Log
if (jwplayer && jwplayer('player_' + vod_id)) {
jwplayer('player_' + vod_id).onPlay(function () {
if (VodPlayList[vod_id] == "false") {
VodPlayList[vod_id] = "true"; // 최초 1회만 로그카운트 기록 수행
//if (typeof (fnLogCounter) == "function") {
//fnLogCounter(vod_id, vodInfo.vod_section, opts.userid);
var vod_logger = "http://counter.jtbc.joins.com/bin/ArticleCounterLogger.dll?Total_ID=" + vod_id + "&Ctg_ID=00&Master_Code=&comm1="+ _vod_pay +"&comm2="+ _vod_paydiv +"&comm3="+ _vod_payamount +"&memid="+ opts.userid +"&gubun="+ device_info +"&cloc=&ref="+ ((typeof(ref) != "undefined") ? ref : "") +"&svc=T";
jQuery("body").append("");
//}
}
});
}
}
} // end of Web
else if (device_info == "M" || device_info == "P") {
jQuery("#div_" + vod_id).html("
" +
"
");
//jQuery("#div_" + vod_id).html("");
// Video Tag용 Play Log
VodPlayList[vod_id] = "false";
jQuery("#player_" + vod_id).bind("play", function () {
if (VodPlayList[vod_id] == "false") {
VodPlayList[vod_id] = "true";
var vod_logger = "http://counter.jtbc.joins.com/bin/ArticleCounterLogger.dll?Total_ID=" + vod_id + "&Ctg_ID=00&Master_Code=&comm1="+ _vod_pay +"&comm2="+ _vod_paydiv +"&comm3="+ _vod_payamount +"&memid=" + opts.userid + "&gubun=" + device_info + "&cloc=&ref=" + ((typeof(ref) != "undefined") ? ref : "") + "&svc=T";
jQuery("head").append("");
}
});
}
} // end of check "div_"+ vod_id area
}
}); // end of getJson
}
function fnVodPlayWizard(vod_id, ref, options) {
// 기본 옵션
var default_options = { width: 480, height: 299, adsn: "14" };
// param으로 들어온 옵션을 기본 옵션과 병합
var opts = jQuery.extend({}, default_options, options);
var _vod_memid = "", _vod_packcode = "", _vod_pay = "N", _vod_paydiv = "00", _vod_payamount = "0";
try { _vod_memid = getCookieA("MemArray","MemID"); } catch(e) {}
var device_info = "W"
if (typeof (mobile_device_detect) == "function") { device_info = mobile_device_detect(); }
jQuery.getJSON("http://article.joins.com/news/jtbc/get_vod_jsondata.asp?callback=?&vodid=" + vod_id +"&m="+ device_info, function (data) {
if (data != null && data != {}) {
var vodInfo = data.vod_info;
var params = {};
params.width = opts.width;
params.height = opts.height;
params.image = vodInfo.img_url;
if (typeof(vodInfo.file_url) != "undefined" && vodInfo.file_url.indexOf("rtmp://") > -1) {
var arr_file_url = vodInfo.file_url.split("&file=");
params.provider = "rtmp";
params.streamer = escape(arr_file_url[0]);
params.file = escape(arr_file_url[1]);
} else {
params.file = vodInfo.file_url;
params.provider = "http"
}
if (jQuery("#mediaspace").length > 0) {
if (device_info == "W") {
if (params.file == "") {
jQuery('#mediaspace').html("
");
} else {
params.flashplayer = "http://fs.jtbc.joins.com/common/ctl/player/player.swf";
params.skin = "http://fs.jtbc.joins.com/common/ctl/player/glow.zip";
var so = new SWFObject(params.flashplayer, 'ply', params.width, params.height, '9', '#000000');
so.addParam('allowfullscreen', 'true');
so.addParam('allowscriptaccess', 'always');
so.addParam('wmode', 'opaque');
so.addVariable('stretching', 'fill');
// so.addVariable('icons','false');
so.addVariable('provider', params.provider); // Protocol(고정)
so.addVariable('streamer', params.streamer); // VOD URL Path
so.addVariable('file', params.file); // VOD URL 중 파일명
so.addVariable('image', params.image); // Thumbnail Image URL - VOD에 따라 변경
so.addVariable('skin', params.skin);
/*if (opts.ad_presn != "" || opts.ad_postsn != "") {
// 광고 연결
var ad_url = 'http://dgate.jtbc.joins.com/xc.aspx?presn=' + opts.ad_presn + '&postsn=' + opts.ad_postsn + '&vt=' + opts.ad_vt;
so.addVariable('plugins', 'adtvideo'); // AD Plugin(고정)
so.addVariable('adtvideo.config', ad_url); // AD 정보 XML 파일 URL
if (typeof (console) == "object") { console.log("load ad : " + ad_url); }
}*/
so.addVariable('controlbar', 'bottom');
so.write("mediaspace");
if (jwplayer('ply') != null) {
jwplayer('ply').onPlay(function () {
if (typeof (jwplayer_onPlay) != 'undefined'){ jwplayer_onPlay();
var vod_logger = "http://counter.jtbc.joins.com/bin/ArticleCounterLogger.dll?Total_ID=" + vod_id + "&Ctg_ID=00&Master_Code="+ _vod_packcode +"&comm1="+ _vod_pay +"&comm2="+ _vod_paydiv +"&comm3="+ _vod_payamount +"&memid="+ _vod_memid +"&gubun="+ device_info +"&cloc=&ref="+ ((typeof(ref) != "undefined") ? ref : "") +"&svc=B";
jQuery("body").append("");
}
});
jwplayer('ply').onComplete(function () {
if (typeof (jwplayer_onComplete) != 'undefined') jwplayer_onComplete();
});
}
}
} // end of web player
else if (device_info == "M" || device_info == "P") { // Molbile Player 처리
if (vodInfo.mobile_file_url == "") {
jQuery('#mediaspace').html("
");
}
else
{
jQuery("#mediaspace").html("
" +
"
");
//jQuery("#mediaspace").html("");
// Video Tag용 Play Log
VodPlayList[vod_id] = "false";
jQuery("#ply").bind("play", function () {
if (VodPlayList[vod_id] == "false") {
if (typeof (jwplayer_onPlay) == "function") {
jwplayer_onPlay();
VodPlayList[vod_id] = "true";
var vod_logger = "http://counter.jtbc.joins.com/bin/ArticleCounterLogger.dll?Total_ID=" + vod_id + "&Ctg_ID=00&Master_Code="+ _vod_packcode +"&comm1="+ _vod_pay +"&comm2="+ _vod_paydiv +"&comm3="+ _vod_payamount +"&memid="+ _vod_memid +"&gubun="+ device_info +"&cloc=&ref="+ ((typeof(ref) != "undefined") ? ref : "") +"&svc=B";
jQuery("body").append("");
}
}
});
}
}
}
}
}); // end of getJson
}
function mobile_device_detect() {
var UserAgent = navigator.userAgent;
var rtn = "W";
/* 모바일과 패드가 중복되는 구문이 있을 수 있어 패드에 해당하는 string이 나오면 패드로 처리 */
//if (UserAgent.match(/iPhone|iPod|Android|Windows CE|BlackBerry|Symbian|Windows Phone|webOS|Opera Mini|Opera Mobi|POLARIS|IEMobile|lgtelecom|nokia|SonyEricsson/i) != null || UserAgent.match(/LG|SAMSUNG|Samsung/) != null) {
if (UserAgent.match(/iPhone|iPod|Android|Windows CE|BlackBerry|Symbian|Windows Phone|webOS|Opera Mini|Opera Mobi|POLARIS|IEMobile|lgtelecom|nokia|SonyEricsson/i) != null) {
rtn = "M";
}
if (UserAgent.match(/iPad/i) != null) {
rtn = "P";
}
return rtn;
}