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

bili-player

v0.0.5

Published

一个模拟B站播放器的视频组件

Downloads

13

Readme

效果图

效果图

快速开始

npm i bili-player

<template>
  <bili-player
    ref="biliPlayerRef"
    style="width: 900px; height: 550px"
    v-bind="playerProps"
  />
</template>

<script setup lang="ts">
import "bili-player/style.css";
import { onMounted, ref } from "vue";
import {
  BiliPlayer,
  type BiliDanmakuItem,
  type BiliPlayerProps,
} from "bili-player";

const biliPlayerRef = ref<InstanceType<typeof BiliPlayer>>();
const playerProps: BiliPlayerProps = {
  video: {
    poster: "https://i.loli.net/2019/06/06/5cf8c5d9c57b510947.png",
    url: "https://api.dogecloud.com/player/get.mp4?vcode=5ac682e6f8231991&userId=17&ext=.mp4",
    autoplay: true,
  },
  danmaku: {
    sendCallback: async (data: BiliDanmakuItem) => {
      // request send
    },
    filter: (data: BiliDanmakuItem) => {
      // 屏蔽弹幕 '前方高能'
      return !data.content.includes("前方高能");
    },
  },
};

const danmaItems: BiliDanmakuItem[] = [
  { content: "君だよ 君なんだよ  教えてくれた", time: 1, type: 0, color: "white" },
  { content: "Goose house炒鸡棒!!!  银之匙种草他们组合", time: 1.2, type: 2, color: "red" },
  { content: "朱军,拔剑吧", time: 1.6, type: 0, color: "green" },
  { content: "听了好多次", time: 6.6, type: 1, color: "white" },
  { content: "带耳机听,贝斯的声音会更加带感!", time: 4.3, type: 0, color: "black" },
  { content: "胖子哥声音太美", time: 3.2, type: 1, color: "white" },
  { content: "练习室版本吧。就像live和专辑。", time: 3.6, type: 0, color: "white" },
  { content: "左下角的妹子唱副歌的,很难的", time: 2.2, type: 1, color: "blue" },
];
onMounted(() => {
  const danmaControl = biliPlayerRef.value?.getDanmaControls();
  danmaControl?.setDanmakus(danmaItems);
});
</script>

参数说明

| 名称 | 类型 | 描述 | 默认值 | | ---------------------- | ----------------------------------------------------- | ------------------------------------ | ------ | | hotkey | boolean | 开启快捷键 | true | | video | BiliVideoProps | 视频参数 | | | video.url | string | 视频路径 | | | video.poster | string | 封面路径 | | | video.track | string | 字幕路径 | | | video.loop | boolean | 是否循环播放 | false | | video.autoplay | boolean | 是否自动播放 | true | | video.volume | number | 默认音量大小 | 0.5 | | video.rate | number | 播放速率 | 1 | | danmaku | BiliDanmakuProps | | | | danmaku.show | boolean | 展示弹幕 | true | | danmaku.fontRatio | number | 字体大小比率,0.5 - 1.5 | 1 | | danmaku.fontBold | boolean | 字体是否加粗 | false | | danmaku.speed | number | 速度 0.5 - 2.0 | 1 | | danmaku.opacity | number | 不透明度 0 - 1 | 1 | | danmaku.displaySize | number | 显示区域 0.25 - 1 | 1 | | danmaku.visible.move | boolean | 滚动弹幕显示 | true | | danmaku.visible.top | boolean | 顶部弹幕显示 | true | | danmaku.visible.bottom | boolean | 底部弹幕显示 | true | | danmaku.visible.color | boolean | 彩色弹幕显示 | true | | danmaku.sendCallback | (dan: BiliDanmakuItem) => Promise | any | 发送弹幕回调,若不发送,抛出错误即可 | | | danmaku.filter | (dan: BiliDanmakuItem) => boolean | Promise | 弹幕显示过滤 | |

API说明

| 名称 | 描述 | | ---------------- | -------------------------------------------------------- | | getVideoControls | 获取视频控制器,返回基于vueuse的useMediaControls的返回值 | | getDanmaControls | 获取弹幕控制器 |