All Projects → bytedance → Danmu.js

bytedance / Danmu.js

Licence: mit
HTML5 danmu (danmaku) plugin for any DOM element

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Danmu.js

Commentcorelibrary
Javascript Live Comment (Danmaku) Engine Implementation. JS弹幕模块核心,提供从基本骨架到高级弹幕的支持。
Stars: ✭ 1,724 (+1226.15%)
Mutual labels:  danmaku, danmu, html5
Danmu Client
A cross-platforms danmaku client that supports transparency which based on canvas + WebSocket. 多用跨平台透明弹幕客户端,支持图文弹幕,基于canvas + WebSocket。
Stars: ✭ 151 (+16.15%)
Mutual labels:  danmaku, danmu
Danmu Server
A danmaku server based on WebSocket. 弹幕服务器,基于WebSocket。
Stars: ✭ 169 (+30%)
Mutual labels:  danmaku, danmu
awesome-danmaku
一款轻量、适用于 H5 弹幕场景的 JS lib。🚀🚀
Stars: ✭ 35 (-73.08%)
Mutual labels:  danmaku, danmu
Artplayer
🎨 ArtPlayer.js is a modern and full featured HTML5 video player
Stars: ✭ 484 (+272.31%)
Mutual labels:  danmu, html5
Ocbarrage
iOS 弹幕库 OCBarrage, 同时渲染5000条弹幕也不卡, 轻量, 可拓展, 高度自定义动画, 超高性能, 简单易上手; A barrage render-engine with high performance for iOS. At the same time, rendering 5000 barrages is also very smooth, lightweight, scalable, highly custom animation, ultra high performance, simple and easy to use!
Stars: ✭ 294 (+126.15%)
Mutual labels:  danmaku, danmu
acfundanmu
AcFun直播API
Stars: ✭ 27 (-79.23%)
Mutual labels:  danmaku, danmu
Danmaku
live video comments protocol and platform api
Stars: ✭ 70 (-46.15%)
Mutual labels:  danmaku, danmu
Danmaku
A high-performance JavaScript danmaku engine. 高性能弹幕引擎库
Stars: ✭ 446 (+243.08%)
Mutual labels:  danmaku, danmu
Kikoplay
KikoPlay - NOT ONLY A Full-Featured Danmu Player 不仅仅是全功能弹幕播放器
Stars: ✭ 313 (+140.77%)
Mutual labels:  danmaku, danmu
Ocbarrage
iOS 弹幕库 OCBarrage, 同时渲染5000条弹幕也不卡, 轻量, 可拓展, 高度自定义动画, 超高性能, 简单易上手; A barrage render-engine with high performance for iOS. At the same time, rendering 5000 barrages is also very smooth, lightweight, scalable, highly custom animation, ultra high performance, simple and easy to use!
Stars: ✭ 589 (+353.08%)
Mutual labels:  danmaku, danmu
Danmu.server
一个开源的弹幕后端
Stars: ✭ 92 (-29.23%)
Mutual labels:  danmaku, danmu
Notifications
HTML5 Notifications API implementation for Microsoft Blazor
Stars: ✭ 122 (-6.15%)
Mutual labels:  html5
Bide
A simple routing library for ClojureScript
Stars: ✭ 124 (-4.62%)
Mutual labels:  html5
W3develops
The w3develops.org open source codebase - Learn, build, and meetup with other developers on DISCORD https://discord.gg/WphGvTT and YOUTUBE http://bit.ly/codingyt
Stars: ✭ 120 (-7.69%)
Mutual labels:  html5
Notes
胡写一通,乱写一气.杂七杂八.记录日常,若喜欢请Star,然后。。。。
Stars: ✭ 119 (-8.46%)
Mutual labels:  html5
Fast
Develop, build, deploy, redeploy, and teardown frontend projects fast.
Stars: ✭ 126 (-3.08%)
Mutual labels:  html5
Chihu2
ionic2-example <吃乎2>混合开发-美食app 🍜 ☕️ 🍦 (This is a support android and apple ionic2 case, a food app)
Stars: ✭ 124 (-4.62%)
Mutual labels:  html5
Vime
Customizable, extensible, accessible and framework agnostic media player. Modern alternative to Video.js and Plyr. Supports HTML5, HLS, Dash, YouTube, Vimeo, Dailymotion...
Stars: ✭ 1,928 (+1383.08%)
Mutual labels:  html5
Freeciv Web
Freeciv-web is an Open Source strategy game implemented in HTML5 and WebGL, which can be played online against other players, or in single player mode against AI opponents.
Stars: ✭ 1,626 (+1150.77%)
Mutual labels:  html5

概述

运用danmu.js可以方便地使用弹幕功能,满足任意Web DOM元素使用(包括video)。弹幕实现了顶部居中、底部居中、彩色弹幕、无遮挡滚动(具体算法参考前端算法之弹幕设计),以及其它常用的弹幕使用方式。

起步

  1. 安装

    $ npm install danmu.js
    
  2. 使用

  • Step 1:

    <div id="vs"></div>
    <video id="mse" controls>
      <source src="demo.mp4" type="video/mp4">
    </video>
    
  • Step 2:

    import DanmuJs from 'danmu.js'
    
    let danmujs = new DanmuJs({
      container: document.getElementById('vs'), //弹幕容器,该容器发生尺寸变化时会自动调整弹幕行为
      containerStyle: { //弹幕容器样式
        zIndex: 100
      },
      player: document.getElementsByTagName('video')[0], //配合音视频元素(video或audio)同步使用时需提供该项
      comments: [ //弹幕预存数组,配合音视频元素(video或audio)同步使用时需提供该项
        {
          duration: 20000, //弹幕持续显示时间,毫秒(最低为5000毫秒)
          //moveV: 100, //弹幕匀速移动速度(单位: px/秒),设置该项时duration无效
          id: '1', //弹幕id,需唯一
          start: 2000, //弹幕出现时间(毫秒)
          prior: true, //该条弹幕优先显示,默认false
          color: true, //该条弹幕为彩色弹幕,默认false
          txt: '长弹幕长弹幕长弹幕长弹幕长弹幕', //弹幕文字内容
          style: {  //弹幕自定义样式
            color: '#ff9500',
            fontSize: '20px',
            padding: '2px 11px',
          },
          mode: 'top' //显示模式,top顶部居中,bottom底部居中,scroll滚动,默认为scroll
          like: { // 点赞相关参数
            el: likeDOM, // el 仅支持传入 dom 
            style: { // el 绑定样式
              paddingLeft: '10px',
              color: '#ff0000'
            }
          }
          // el: DOM //直接传入一个自定义的DOM元素作为弹幕,使用该项的话会忽略所提供的txt和style
        }
      ],
      area: {  //弹幕显示区域
        start: 0, //区域顶部到播放器顶部所占播放器高度的比例
        end: 1 //区域底部到播放器顶部所占播放器高度的比例
      },
      channelSize: 40, // 轨道大小
      mouseControl: true, // 打开鼠标控制, 打开后可监听到 bullet_hover 事件。danmu.on('bullet_hover', function (data) {})
      mouseControlPause: false, // 鼠标触摸暂停。mouseControl: true 生效
      //bOffset: 1000, //可调节弹幕横向间隔(毫秒)
      defaultOff: true //开启此项后弹幕不会初始化,默认初始化弹幕
    })
    

这是danmu.js的npm使用方法,cdn使用可以参考示例。DEMO

API

弹幕控制相关API

player.danmu.start() //弹幕初始化并播放(内部默认已调用)
player.danmu.pause() //弹幕暂停
player.danmu.play() //弹幕继续播放
player.danmu.stop() //弹幕停止并消失
player.danmu.sendComment({  //发送弹幕
    duration: 15000,
    id: 'id',
    start: 3000, //不提供该项则立即发送
    txt: '弹幕内容',
    style: {
        color: '#ff9500',
        fontSize: '20px',
        border: 'solid 1px #ff9500',
        borderRadius: '50px',
        padding: '5px 11px',
        backgroundColor: 'rgba(255, 255, 255, 0.1)'
    }
})
player.danmu.setCommentDuration(id, duration) //按照id改变某一个弹幕的持续显示时间
player.danmu.setAllDuration(mode, duration) //改变所有已加入队列弹幕的持续显示时间
player.danmu.setCommentID(oldID, newID) //改变某一个弹幕的id
player.danmu.hide(mode) //屏蔽某一类弹幕(参数可选值 scroll | top | bottom | color)
player.danmu.show(mode) //显示某一类弹幕(参数可选值 scroll | top | bottom | color)
player.danmu.setArea(area) // 修改弹幕显示区域
player.danmu.setOpacity(opacity) // 设置透明度
player.danmu.setFontSize(size, channelSize) // 设置样式 size 为字体大小 channelSize 如果不需要修改轨道大小则无需传入 channelSize
danmu.setCommentLike(id, {
    el: likeDOM,
    style: {
        paddingLeft: '10px',
        color: '#ff0000'
    }
}) // 这是点赞样式,id 为 commentid

Dev

我们为开发者提供了示例,使用方式如下:

$ git clone [email protected]:bytedance/danmu.js.git
$ cd danmu.js
$ npm install
$ npm run build
$ http-server

访问 http://localhost:8080/demo/index.html

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].