(function( window, undefined ) {
var document = window.document,
navigator = window.navigator,
location = window.location;
var ctVideoServer = {
name: "CmsTop Video Server 1.0",
video: '',
videoId: 'cmstop_video_',
ishtml5: 0,
video_type: 'video/mp4',
isVideoCanPlay: function(video_type)
{
var video_element = document.createElement('video');
if(typeof(video_element.canPlayType)=='undefined')
{
return false;
}
var result = video_element.canPlayType(video_type || this.video_type);
if((result=='probably')||(result=='maybe'))
{
return true;
}
return false;
},
isMobile: function(){
var ua = navigator.userAgent;
if(/iPad/i.test(ua) || /iPhone/i.test(ua) || /iPod/i.test(ua) || /Android/i.test(ua)) {
return true;
}else if(/palm/i.test(ua) || /webos/i.test(ua)){
return true;
}else{
return false;
}
},
resize: function(){
if(this.ishtml5){
var vid = this.videoId;
var obj = document.getElementById(vid);
obj.height = obj.videoHeight;
return true;
}
},
render: function() {
if(true || this.isMobile()){
//支持html5 video标签,并且可以播放mp4格式
video = '';
video += ''
this.ishtml5 = 1;
}else{
var flashvars = 'onPlay=onPlayJS&onPause=onPauseJS&onPlayed=onPlayedJS&onPlayerReady=onPlayerReadyJS&onEndFinish=onEndFinishJS&vid=19148';
video = '';
}
return video;
},
init: function(){
document.writeln(this.render());
//window.setTimeout("ctVideoServer.resize()",500);
},
renderAt: function(elemid) {
var elem = elemid && document.getElementById(elemid);
if (!elem) return false;
elem.innerHTML = this.render();
('jQuery' in window) && jQuery('#' + elemid).trigger('change.ctVideoServer');
},
getMovie: function(){
var i, videoObj, obj, objs = [this.videoId+'_embed', this.videoId+'_object', this.videoId];
for(i in objs){
obj = objs[i];
videoObj = document[obj] ? document[obj] : (window[obj] ? window[obj] : undefined);
if(videoObj){
if(typeof(videoObj.playVideo) == "function") break;
}
}
return videoObj;
}
};
window.ctVideoServer = ctVideoServer;
})(window);
ctVideoServer.init();