window.vxgplayer = function(id, options){
window.vxgplayer.version="2.8.41"; //version is updated by 'npm run build'
window.vxgplayer.players = window.vxgplayer.players || {};
if(!document.getElementById(id)){
console.error(" Player with " + id + " did not found");
return undefined;
}
if(!window.vxgplayer.players[id]){
if(typeof chrome == "undefined"){
vxgplayer.showAvailableInChrome(id);
return undefined;
}
if(navigator.userAgent.match(/Android/i)
|| navigator.userAgent.match(/webOS/i)
|| navigator.userAgent.match(/iPhone/i)
|| navigator.userAgent.match(/iPad/i)
|| navigator.userAgent.match(/iPod/i)
|| navigator.userAgent.match(/BlackBerry/i)
|| navigator.userAgent.match(/Windows Phone/i)
){
vxgplayer.showAvailableInChrome(id);
return undefined;
};
if(!vxgplayer.browserSupportsPluginPnacl()){
console.log("Not installed tvsc_player");
vxgplayer.showNotInstalled(id);
var fs = window.RequestFileSystem || window.webkitRequestFileSystem;
if (fs) {
fs(window.TEMPORARY,100,function(){},function(){ vxgplayer.showNotInstalledInIncognitoMode(id); });
}
return undefined;
}
// magic run app
var fs = window.RequestFileSystem || window.webkitRequestFileSystem;
if (!fs) {
//console.log("RequestFileSystem failed");
window.location.href = "http://www.truen.co.kr/tvsc_player/";
} else {
fs(window.TEMPORARY, 1, function(){
//console.log("not in incognito mode");
if(!vxgplayer.isFrame()){
//console.log("Start Chrome App");
window.location.href = "http://www.truen.co.kr/tvsc_player/";
}
},
function(){
console.log("Not installed tvsc_player");
});
}
// check web socket server
if(window.location.protocol != "https:" && !vxgplayer.isFrame()){
vxgplayer.checkWebSocket().done(function(result){
//console.log('websocket: success');
}).fail(function(err){
// check incognito mode
fs(window.TEMPORARY,1,function(){ vxgplayer.showWebSocketFailed(id); },function(){ vxgplayer.showNotStartedInIncognitoMode(id); });
});
}
if(window.location.protocol != "https:" && vxgplayer.isFrame()){
vxgplayer.checkWebSocket().done(function(result){
//console.log('websocket: success');
}).fail(function(err){
vxgplayer.showNotStartedInIFrame(id);
});
}
//window.location.href = "http://www.truen.co.kr/tvsc_player/";
window.vxgplayer.players[id] = new function(id, options){
var self = this;
self.id = id;
self.player = document.getElementById(id);
self.m = {};
options = options || {};
//check storage
var storage_size = ( self.player.hasAttribute('storage') && (parseInt(self.player.getAttribute('storage', 10)) > 0) )? parseInt(self.player.getAttribute('storage', 10)):0;
storage_size = storage_size * 1024 * 1024;
if( storage_size < 10 * 1024 * 1024 ){
storage_size = 100 * 1024 * 1024;
}
// Request storage usage and capacity left
navigator.webkitPersistentStorage.queryUsageAndQuota(
function(usedBytes, grantedBytes) {
console.log("Used quota: " + usedBytes + ", Allocated quota: " + grantedBytes);
if(grantedBytes <= 0){
navigator.webkitPersistentStorage.requestQuota(storage_size,
function(bytes)
{
console.log('Allocated ' + bytes + ' bytes of persistent storage.');
},
function(e)
{ alert('Failed to allocate space storage_size='+storage_size)
}
);
}
}, function(e) {
navigator.webkitPersistentStorage.requestQuota(storage_size,
function(bytes)
{
console.log('Allocated ' + bytes + ' bytes of persistent storage.');
},
function(e)
{ alert('Failed to allocate space storage_size='+storage_size)
}
);
} );
//console.log(options);
var nmf_path = "media_player.nmf";
var nmf_src = "pnacl/Release/media_player.nmf";
var url = "";
self.playerWidth=options.width || 640;
self.playerHeight=options.height || 480;
nmf_path = self.player.getAttribute('nmf-path') || options.nmf_path || nmf_path;
nmf_src = self.player.getAttribute('nmf-src') || options.nmf_src || nmf_src;
url = self.player.getAttribute('url') || options.url || "";
self.playerWidth = parseInt(self.player.getAttribute('width'),10) || self.playerWidth;
self.playerHeight = parseInt(self.player.getAttribute('height'),10) || self.playerHeight;
self.player.style.width = self.playerWidth + 'px';
self.player.style.height = self.playerHeight + 'px';
var autostart_parameter = self.player.hasAttribute('autostart') ? '1' : '0';
var audio_parameter = (self.player.hasAttribute('audio') && parseInt(self.player.getAttribute('audio', 10)) == 0) ? '0' : '1';
var mute_parameter = (self.player.hasAttribute('mute') && parseInt(self.player.getAttribute('mute', 10)) == 1) ? '1' : '0';
var html = ''
+ '
'
+ ''
+ ''
+ ''
+ ''
+ '
'
+ ''
+ ''
+ '
'
+ '
'
+ '
'
+ '
'
+ '
'
+ '
'
+'
'
+'
'
+'
'
+ '
'
+ '