Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lin-media/danmaku

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lin-media/danmaku

danmaku

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

弹幕

安装

npm i @lin-media/danmaku

初始化

import MediaPlayer from "@lin-media/player";
import Danmaku from "@lin-media/danmaku";
MediaPlayer.use(Danmaku);

const player = new MediaPlayer({
  // ...
  Danmaku: {
    // 弹幕字体颜色,随机
    fontColors: ["blue", "red", "green", "#fff"],
    // 弹幕字体大小随机
    fontSizes: [16, 18, 20, 22, 24, 26, 28]
  }
});

Danmaku 参数

参数说明类型可选值默认值
trackSize轨道高度number12
renderInterval弹幕数据队列默认轮询间隔时间number150
speedArg移动速率number0.0058
discardTime弹幕的超时时间,超过时间会被丢弃number5 _ 60 _ 1000
fontColors弹幕字体颜色,随机Array
fontSizes弹幕字体大小,随机Array

API

  • player.danmaku.send(message):发送消息弹幕,message 格式见下方
  • player.danmaku.play():开始弹幕
  • player.danmaku.pause():暂停弹幕
  • player.danmaku.resize():容器发生变化时调用
  • player.danmaku.clearScreen():清屏,移除所有弹幕
  • player.danmaku.close():关闭弹幕
  • player.danmaku.open():打开弹幕

message 格式

  • player.danmaku.send('你好')
  • player.danmaku.send({text:'你好',fontColor:30})
  • player.danmaku.send([{text:'你好',fontColor:30},{text:'世界',fontColor:'blue'}])

当参数是Object或者Array类型时,下列字段可选

字段说明类型
text弹幕文本string
fontSize字体大小number
fontColor字体颜色string
rollTime弹幕移动时间,单位秒number

自定义语言包

MediaPlayer.useLang({
  danmaku: {
    full: "全屏",
    top: "顶部",
    bottom: "底部",
    pause: "暂停弹幕",
    show: "显示弹幕",
    opacity: "透明度",
    speed: "弹幕速度",
    showArea: "显示区域"
  }
});

Keywords

FAQs

Package last updated on 05 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc