GithubHelp home page GithubHelp logo

wyrover / danmu-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zsxsoft/danmu-client

0.0 2.0 0.0 240 KB

A cross-platforms danmaku client that supports transparency which based on canvas + WebSocket. 多用跨平台透明弹幕客户端,支持图文弹幕,基于canvas + WebSocket。

JavaScript 85.27% HTML 8.78% PowerShell 5.95%

danmu-client's Introduction

danmu-client

Github All Releases David deps

这是一个独立的弹幕客户端,其服务端项目见danmu-server

功能特色

  • WebSocket作为通讯协议,用Canvas作为弹幕的画布;
  • 可在桌面任何位置显示弹幕,可与其他程序共同工作;
  • 窗口置于最前,完全透明可穿透,用户可用键鼠等与其他程序正常交互;
  • 提供紧急清空弹幕池、停止接收弹幕等功能;
  • 支持图片弹幕。

兼容性警告

欲编译Windows XP可用版本,请使用master分支下的nwjs版本!

直接启动程序

  1. 打开Release下载已经编译好的程序包并解压到某目录。
  2. 双击目录下的danmu-client.exe,启动成功。

源代码部署说明

  1. 下载并安装Nodejs,同时需要安装Visual StudioPython以便编译C++组件。
  2. 命令行切换到工程目录下,执行npm install,等待自动下载和编译组件。(如果不想通过npm下载electron,可以在package.json里去掉electron-prebuilt)。
  3. 执行electron .,启动成功。

发布说明(Windows x86 + x64)

  1. 根据danmu.png手动生成一个danmu.ico
  2. npm install node-gyp electron-packager -g
  3. PowerShell运行pack.ps1,完成。

配置说明

根目录config.js下有配置,以下是说明

socket: {
    url: "弹幕服务器开启的IP与端口(如使用反代,需要确认反代支持WebSocket连接)",
    password: "弹幕服务器连接密码",
    room: "选择连接弹幕服务器的某间房间",
    heartbeat: 心跳包发送间隔
},
display: {
    comment: {
        animationStyle: "默认弹幕样式(支持scroll、reversescroll、staticdown、staticup)",
        fontStyle: "默认字体样式",
        fontColor: "默认颜色",
        lifeTime: 每条弹幕的基本存活时间,
        height: 每条弹幕占据高度
    }, 
    image: 图片弹幕开关
}, 
image: {
    regex: 图片判断正则,勿动
    whitelist: [
        "图片弹幕允许加载的网络图片白名单。", 
        "不支持通配符,必须一条一条手动添加。", 
        "请确认图片可以正常被打开。"
    ], 
    preload: 网络图片是否预读缓存
}

图片弹幕

打开图片弹幕开关后,弹幕内含相关内容的将被解析为图片。图片必须可以正常打开,调用代码如:[IMG WIDTH=24]danmu-24.png[/IMG]。格式:[IMG WIDTH=图片宽度]图片地址(支持HTTP)[/IMG]

为了保证安全与稳定,图片弹幕有防火墙机制。只有在弹幕程序目录及子目录下存在的图片才可被加载。引用网络图片,必须手动修改config.js添加白名单规则。如果被过滤,则程序不会有任何提示,该弹幕也不会被显示。

自定义弹幕

需要在服务器打开相应开关后,才允许使用自定义弹幕功能。自定义弹幕必须返回一个函数(或类),继承自lib/danmu/sprite.js中的Sprite,并需要实现updateLifeTime方法和draw方法,有alive属性。 示例代码如下(生成一个颜色随机、在屏幕上晃来晃去的玩意):

var Sprite = require('./lib/danmu/sprite.js');
var canvasWidth = 0;
var canvasHeight = 0;
function Comment(param) {
    Sprite.call(this, param.x, param.y, param.width, param.height, param.speed);
    this.text = param.text || ""; //文字内容
    this.lifeTime = param.lifeTime || config.display.comment.lifeTime;
    this.font = param.font || config.display.comment.fontStyle;
    this.alive = true; //生命状态
}
Comment.prototype = Object.create(Sprite.prototype);
Comment.prototype.draw = function (canvasContext) {
    if (canvasWidth === 0) canvasWidth = canvasContext.canvas.width;
    if (canvasHeight === 0) canvasHeight = canvasContext.canvas.height;
    canvasContext.fillStyle = "rgb(" + parseInt(Math.random() * 255) + ", " + parseInt(Math.random() * 255) + ", " + parseInt(Math.random() * 255) + ")";
    canvasContext.font = this.font;
    canvasContext.fillText(this.text, parseInt(Math.random() * canvasWidth), parseInt(Math.random() * canvasHeight));
};
Comment.prototype.updateLifeTime = function () {
    this.lifeTime--; //每刷新一帧,存活时间-1
    this.alive = (this.lifeTime >= 0);
};
return Comment;

开源协议

The MIT License (MIT)

博文

弹幕服务器及搭配之透明弹幕客户端研究结题报告

弹幕服务器及搭配之透明弹幕客户端研究中期报告

弹幕服务器及搭配之透明弹幕客户端研究开题报告

开发者

zsx - http://www.zsxsoft.com / 博客 - http://blog.zsxsoft.com

感谢

DDPlayer by dpy1123

danmu-client's People

Contributors

zsxsoft avatar

Watchers

James Cloos avatar wyrover avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.