Skip to content

Commit

Permalink
加了个弹幕
Browse files Browse the repository at this point in the history
  • Loading branch information
Volio committed Apr 17, 2016
1 parent 588d8f0 commit ced2401
Show file tree
Hide file tree
Showing 5 changed files with 653 additions and 1 deletion.
12 changes: 12 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,16 @@ a{
}
.site-title{
cursor: pointer;
}
.danmuarea{
position: absolute;
width: 100%;
z-index: 10;
}
#player{
position: absolute;
width: 100%;
}
.danmaku{
font-family: "SimHei" !important;
}
26 changes: 26 additions & 0 deletions public/js/danmaku.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ function showMessage(name, data) {
var div = document.createElement('div');
div.className = 'user-danmaku';
div.innerHTML = msg;
sendDanmaku(encodeHTML(data));
printWall.appendChild(div);
if(printWall.childNodes.length>150){
printWall.removeChild(printWall.childNodes[0]);
Expand Down Expand Up @@ -141,4 +142,29 @@ function sendMsg() {
printWall.scrollTop = printWall.scrollHeight;
});
}
}

$("#danmu").danmu({
left:0,
top:5,
height:180,
width:"100%",
speed:7000,
opacity:1,
font_size_small:16,
font_size_big:24,
top_botton_danmu_time:6000
});

$('#danmu').danmu('danmuStart');

function sendDanmaku(message){
var text = message;
var color = "#FFFFFF";
var position = 0;
var time = $('#danmu').data("nowTime")+1;
var size = 1;
var text_obj='{ "text":"'+text+'","color":"'+color+'","size":"'+size+'","position":"'+position+'","time":'+time+'}';
var new_obj=eval('('+text_obj+')');
$('#danmu').danmu("addDanmu",new_obj);
}
2 changes: 2 additions & 0 deletions public/js/index.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
* Created by Volio on 2016/3/12.
*/
$(document).ready(function(){
$("#playcard").css("height",$("#playcard").width()*0.5625+"px");
$("#player").css("height",$("#player").width()*0.5625+"px");
$("#comments").css("height",$("#player").width()*0.5625+"px");
$(window).resize(function(){
$("#playcard").css("height",$("#playcard").width()*0.5625+"px");
$("#player").css("height",$("#player").width()*0.5625+"px");
$("#comments").css("height",$("#player").width()*0.5625+"px");
});
Expand Down
Loading

0 comments on commit ced2401

Please sign in to comment.