npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

moedan

v1.2.0

Published

A simple danmaku engine

Downloads

49

Readme

moedan

简单、小巧、实用的弹幕引擎

How to use

npm i moedan -S
import Moedan from 'moedan'

const danmakuDada = [
  {
    content: '666',
    time: 1.22
  },
  {
    content: 'did a good job',
    time: 8.90
  }
]
const player = document.querySelector('video.myvoideo')
const Danmaku = new Moedan({
  data: danmakuData,
  container: document.querySelector('.danmaku_container'),
  player
})

player.addEventListener('play', () => {
  Danmaku.play()
})

参数

实例化 Moedan 的参数

container

type: HTMLElement

存放弹幕元素的容器元素

data

type: Array

弹幕数据,数据格式需包含 timecontent 属性,分别代表弹幕在视频的时间和内容

[
  {
    content: '666',
    time: 1.22
  },
  {
    content: 'did a good job',
    time: 8.90
  }
]

player

type: HTMLElement

对应的视频元素

tunnels

type: Number

default: 3

出现弹幕的轨道数量

time

type: Number

default: 6

一条弹幕从出现到消失的时间,单位:秒

API

Danmaku.clear()

清除弹幕

Danmaku.clear()

Danmaku.hide()

隐藏弹幕,一般和隐藏弹幕按钮一块使用

Danmaku.pause()

暂停弹幕,应该和视频一起播放

Player.addEventListener('pause', () => Danmaku.play())

Danmaku.play()

播放弹幕,应该和视频一起播放

Player.addEventListener('play', () => Danmaku.play())

Danmaku.reload()

重新 load 弹幕,应该和视频重播一起使用

Player.addEventListener('ended', () => Danmaku.reload())

Danmaku.seek()

重新定位弹幕,一般和拖动播放器进度条一起使用

// when update video's currentTime
Danmaku.seek()

Danmaku.show()

显示弹幕,一般和显示弹幕按钮一块使用