视频弹幕技术 php,手把手教你一个简单弹幕实现php培训

  • Post author:
  • Post category:php


(function(){

varroot=this;

vararray=[];

varpush=array.push;

varslice=array.slice;

varsplice=array.splice;

// The top-level namespace.

varBarrage;

if(typeof exports!==’undefined’){

Barrage=exports;

}else{

Barrage=root.Barrage={};

}

// Current Version of Barrage

Barrage.VERSION=’0.0.1′;

// extends the jquery

Barrage.$=root.jQuery;

Barrage.config={

‘color’:[‘red’,’blue’,’black’,’orange’,’white’],

‘font_family’:[‘Monaco’],

‘font_size’:[’18px’,’20px’,’24px’,’28px’],

‘speed’:[10000,9000,8000,7000,6000,5000,4000]

};

Barrage.random=function(len){

returnMath.random()*len;

};

varbullet=Barrage.bullet=(function(){

var_font_family;

var_font_size;

var_color;

var_speed;

var_x_pos;

var_y_pos;

varrandom_render=function(config_item){

returnconfig_item[Math.floor(Barrage.random(config_item.length))];

};

varlaunch=function(objects,pose){

_font_size=objects.font_size||random_render(Barrage.config.font_size);

_font_family=objects.font_family||random_render(Barrage.config.font_family);

_color=objects.color||random_render(Barrage.config.color);

_speed=objects.speed||random_render(Barrage.config.speed);

_y_pos=objects.y_pos||Math.random()*window.innerHeight;

console.log(_font_size);

console.log(_font_family);

console.log(_color);

console.log(_speed);

console.log(_y_pos);

console.log(“=============”);

if(!objects.content)return;

varwords=Barrage.$(”

“+objects.content+”

“);

words.css(“font-size”,_font_size);

words.css(“font-family”,_font_family);

words.css(“color”,_color);

words.css(“right”,0);

words.css(“position”,”absolute”);

words.css(“top”,_y_pos);

words.attr(“zoom”,1000);

$(“body”).append(words);

Barrage.$(words).animate({

“right”:window.innerWidth

},_speed,function(){

console.log(“finished!”);

});

};

return{

launch:launch

};

})();

varAction=Barrage.Action={

};

}).call(this);