Package Exports
- liveplayer-wrapper
- liveplayer-wrapper/dist/style.css
Readme
LivePlayer Wrapper
Vue 3 wrapper for @liveqing/liveplayer-v3 with recording and playback control features.
🚀 最新更新
v1.2.1 - 重要更新:需要单独引入 video.js:
- ⚠️ 重要变更:现在需要在使用组件前单独引入 video.js
- ✅ 修复了
Uncaught ReferenceError: videojs is not defined错误 - ✅ 优化了依赖管理,将 video.js 设置为 peerDependency
- ✅ 提供了清晰的使用说明和示例
Installation
npm install liveplayer-wrapperDependencies
This component requires the following peer dependencies:
npm install video.js @liveqing/liveplayer-v3Important: You must install and import video.js before using this component. See the usage examples below.
Usage
Global Registration
import { createApp } from 'vue'
import LivePlayerWrapper from 'liveplayer-wrapper'
import 'liveplayer-wrapper/dist/style.css'
// ⚠️ 重要:必须先引入 video.js
import 'video.js/dist/video-js.css'
import videojs from 'video.js'
// 设置 videojs 为全局变量
window.videojs = videojs
const app = createApp(App)
app.use(LivePlayerWrapper)Local Registration
<template>
<LivePlayerWrapper
:video-url="videoUrl"
:video-title="videoTitle"
@ready="onPlayerReady"
@recordingStart="onRecordingStart"
@recordingStop="onRecordingStop"
/>
</template>
<script setup>
import { LivePlayerWrapper } from 'liveplayer-wrapper'
import 'liveplayer-wrapper/dist/style.css'
// ⚠️ 重要:必须先引入 video.js
import 'video.js/dist/video-js.css'
import videojs from 'video.js'
// 设置 videojs 为全局变量
window.videojs = videojs
const videoUrl = 'your-video-stream-url'
const videoTitle = 'Live Stream'
const onPlayerReady = (player) => {
console.log('Player is ready:', player)
}
const onRecordingStart = () => {
console.log('Recording started')
}
const onRecordingStop = () => {
console.log('Recording stopped')
}
</script>Features
- Video playback with live streaming support
- Recording functionality with automatic file download
- Playback controls (play/pause, volume, fullscreen)
- Custom buttons for recording and playback toggle
- Recording protection to prevent data loss
- Responsive design with customizable aspect ratios
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| videoUrl | String | "" | Video stream URL |
| videoTitle | String | "" | Title displayed on video |
| poster | String | "" | Video poster image |
| autoplay | Boolean | true | Auto-play video |
| controls | Boolean | true | Show video controls |
| muted | Boolean | true | Mute video by default |
| aspect | String | "16:9" | Video aspect ratio |
| live | Boolean | true | Live stream mode |
Events
| Event | Parameters | Description |
|---|---|---|
| ready | player | Player is ready |
| recordingStart | - | Recording started |
| recordingStop | - | Recording stopped |
| recordingError | error | Recording error occurred |
| play | time | Video started playing |
| pause | time | Video paused |
| error | error | Player error |
Methods
| Method | Description |
|---|---|
| startRecording() | Start video recording |
| stopRecording() | Stop video recording |
| toggleRecording() | Toggle recording state |
| togglePlayback() | Toggle playback state |
| snap() | Take a screenshot |
Troubleshooting
"videojs is not defined" Error
If you encounter this error, make sure:
You have installed
video.jsas a dependency:npm install video.js
重要:在使用 LivePlayerWrapper 之前,必须先引入 video.js:
import 'video.js/dist/video-js.css' import videojs from 'video.js' // 设置 videojs 为全局变量 window.videojs = videojs
或者在 HTML 中通过 CDN 引入:
<link href="https://vjs.zencdn.net/8.23.4/video-js.css" rel="stylesheet" /> <script src="https://vjs.zencdn.net/8.23.4/video.min.js"></script>
License
MIT