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 🙏

© 2026 – Pkg Stats / Ryan Hefner

liveplayer-vue3

v0.1.1

Published

Enhanced Vue 3 wrapper for @liveqing/liveplayer-v3 with typed API, docs, and playground.

Downloads

110

Readme

liveplayer-vue3

English | 中文

面向 Vue 3 的播放器封装组件,基于 @liveqing/liveplayer-v3,提供:

  • 类型完善的 props、事件与实例方法
  • 自动化 runtime 资源加载
  • VitePress 文档与本地 playground
  • 基于 CI 的 npm 发布与 GitHub Release 流程

安装

pnpm add liveplayer-vue3

Peer 依赖:

  • vue ^3.5.0

快速开始

方式一:作为插件注册

import { createApp } from 'vue';
import App from './App.vue';
import LivePlayerVue3 from 'liveplayer-vue3';
import 'liveplayer-vue3/style.css';

const app = createApp(App);
app.use(LivePlayerVue3);
app.mount('#app');

方式二:按组件直接引入

<script setup lang="ts">
import { LivePlayer } from 'liveplayer-vue3';
import 'liveplayer-vue3/style.css';
</script>

<template>
  <LivePlayer
    src="https://example.com/live.m3u8"
    mode="live"
    controls
    title="演示流"
  />
</template>

Runtime 资源加载机制

组件会在导入底层播放器模块前,先自动加载 runtime 脚本:

  • 默认脚本地址:BASE_URL/assets/liveplayer/liveplayer-lib.min.js
  • 可通过 assetBaseUrl 指定自定义静态资源地址(如 CDN)
  • 加载器内置去重、超时、重试和就绪校验(window.videojs)

使用自定义 CDN 示例:

<LivePlayer
  src="https://example.com/live.m3u8"
  asset-base-url="https://cdn.example.com/liveplayer"
/>

组件 API

Props

| 属性 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | | src | string | 必填 | 播放地址 | | title | string | undefined | 视频标题 | | poster | string | undefined | 封面图 | | mode | 'live' | 'vod' | 'vod' | 播放模式 | | autoplay | boolean | true | 自动播放 | | controls | boolean | false | 是否显示控制条 | | muted | boolean | false | 是否静音 | | loop | boolean | false | 是否循环 | | fit | 'contain' | 'cover' | 'fill' | 'contain' | 画面填充方式 | | timeout | number | 10 | 播放超时 | | playbackRates | number[] | [0.5, 1, 1.5, 2] | 倍速列表 | | playbackRate | number | 1 | 初始倍速 | | resolution | string | undefined | 清晰度提示 | | assetBaseUrl | string | 基于 BASE_URL 推导 | runtime 资源根路径 | | retry | { attempts?: number; delay?: number; backoffMultiplier?: number } | { attempts: 0, delay: 1000, backoffMultiplier: 1 } | 兼容保留参数 | | lowLatency | boolean | false | 兼容保留参数 | | debug | boolean | false | 兼容保留参数 | | class | string | '' | 外层容器 class | | style | CSSProperties | {} | 外层容器 style |

Events

| 事件 | 参数 | 说明 | | --- | --- | --- | | ready | { api, assets } | runtime 就绪,返回公开 API 与资源信息 | | play | currentTime: number | 开始播放 | | pause | currentTime: number | 暂停播放 | | ended | 无 | 播放结束 | | error | { code, message, cause } | 加载/运行时错误 | | message | { message, type } | 底层播放器消息 | | timeupdate | currentTime: number | 播放进度更新 | | volumechange | volume: number, isMuted: boolean | 音量/静音状态变化 | | fullscreen-change | isFullscreen: boolean | 全屏状态变化 | | status-change | 'idle' | 'loading' | 'ready' | 'error' | 'ended' | 组件生命周期状态 |

暴露方法

通过模板 ref 调用:

<script setup lang="ts">
import { ref } from 'vue';
import type { LivePlayerPublicInstance } from 'liveplayer-vue3';

const playerRef = ref<LivePlayerPublicInstance | null>(null);

const jumpToTen = () => {
  playerRef.value?.seek(10);
};
</script>

<template>
  <LivePlayer ref="playerRef" src="https://example.com/video.mp4" />
  <button @click="jumpToTen">跳转到 10 秒</button>
</template>

可用方法:

  • play()
  • pause()
  • seek(time: number)
  • snapshot()
  • setMuted(muted: boolean)
  • setVolume(volume: number)
  • enterFullscreen()
  • exitFullscreen()
  • toggleFullscreen()
  • getInternalPlayer()

Slots

  • empty:当 src 为空时渲染
  • loading:加载态覆盖层
  • error:错误态覆盖层
  • overlay:叠加层,接收 { status }

状态与错误模型

状态流转:

  • 未传 src:idle
  • 加载 runtime / 组件:loading
  • 可播放:ready
  • 播放结束:ended
  • 加载失败或运行时异常:error

错误码:

  • load_failed:runtime 资源或模块加载失败
  • runtime_error:底层播放器抛出错误

SSR 与测试说明

  • 支持 SSR 场景安全导入(非浏览器环境不触发脚本注入)
  • 在 vitest、jsdom、happy-dom 中会跳过真实 runtime 脚本注入

开发

pnpm install
pnpm dev
pnpm dev:docs

构建与校验

pnpm lint
pnpm typecheck
pnpm test
pnpm build
pnpm build:docs
pnpm publint

一键校验:

pnpm verify

发布自动化

GitHub Actions:

  • Prepare Release 工作流使用 bumpp + changelogithub
  • 手动选择版本类型:patch / minor / major
  • 执行 pnpm verify,更新版本与 CHANGELOG,自动提交并打 tag
  • tag 推送后触发 .github/workflows/release.yml,发布 npm 并创建 GitHub Release

本地发布命令:

pnpm release

文档与演示

  • 文档站:pnpm dev:docs
  • 本地演示:pnpm dev

常用文件:

  • docs/.vitepress/config.ts
  • playground/src/demos/FeatureShowcase.vue
  • .github/workflows/release-prepare.yml
  • .github/workflows/release.yml