JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q53276F
  • License MIT

Vue 3 wrapper for @liveqing/liveplayer-v3 with recording and playback control features

Package Exports

  • liveplayer-wrapper
  • liveplayer-wrapper/dist/style.css

Readme

LivePlayer Wrapper

A Vue 3 wrapper component for @liveqing/liveplayer-v3 with enhanced recording and playback control features.

Features

  • 🎥 Video streaming support (HLS, FLV, RTMP, etc.)
  • 📹 Screen recording functionality
  • 🎮 Playback control (play, pause, volume, fullscreen)
  • 🎛️ Customizable UI controls
  • 📱 Responsive design
  • 🎨 Customizable styling
  • 🔧 TypeScript support

Installation

npm install liveplayer-wrapper

Usage

Basic Usage

<template>
  <div>
    <LivePlayerWrapper
      :video-url="videoUrl"
      :video-title="videoTitle"
      @ready="onPlayerReady"
      @recordingStart="onRecordingStart"
      @recordingStop="onRecordingStop"
      @recordingError="onRecordingError"
    />
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { LivePlayerWrapper } from 'liveplayer-wrapper'

const videoUrl = ref('https://example.com/stream.m3u8')
const videoTitle = ref('Live Stream')

const onPlayerReady = (player: any) => {
  console.log('Player is ready:', player)
}

const onRecordingStart = () => {
  console.log('Recording started')
}

const onRecordingStop = () => {
  console.log('Recording stopped')
}

const onRecordingError = (error: string) => {
  console.error('Recording error:', error)
}
</script>

Plugin Installation

import { createApp } from 'vue'
import App from './App.vue'
import LivePlayerWrapper from 'liveplayer-wrapper'

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

Global Component Registration

import { createApp } from 'vue'
import App from './App.vue'
import { LivePlayerWrapper } from 'liveplayer-wrapper'

const app = createApp(App)
app.component('LivePlayerWrapper', LivePlayerWrapper)
app.mount('#app')

Props

Prop Type Default Description
videoUrl string "" Video stream URL
videoTitle string "" Video title displayed in top-right corner
poster string "" Video poster image URL
alt string "无信号" Alternative text when no video
autoplay boolean true Auto-play video
controls boolean true Show control bar
loop boolean false Loop video
live boolean true Is live stream (hide progress bar)
muted boolean true Mute video
aspect string "16:9" Aspect ratio (or "fullscreen")
fluent boolean true Smooth mode
stretch boolean false Stretch video
hideBigPlayButton boolean false Hide big play button
waterMark string "" Watermark text
timeout number 20 M3U8 loading timeout (seconds)
showCustomButton boolean true Show custom buttons
hideSnapshotButton boolean false Hide snapshot button
hideFullscreenButton boolean false Hide fullscreen button
hideFluent boolean false Hide fluent button
hideStretch boolean true Hide stretch button
resolution string "" Resolution config (yh,fhd,hd,sd)
resolutiondefault string "hd" Default resolution
playbackRates number[] [0.5, 1, 2, 3] Playback rate options
playbackRate number 1 Default playback rate
hasaudio boolean undefined Has audio (auto-detect)
hasvideo boolean undefined Has video (auto-detect)
customButtons string "录制:vjs-icon-record,开关:vjs-icon-switch" Custom toolbar buttons
autofocus boolean false Auto focus
dblclickFullscreen boolean true Double-click fullscreen
language string "" Language (zh-CN/en)
digitalZoom boolean false Digital zoom

Events

Event Parameters Description
message { type: string, message: string } M3U8 loading failed
error Error Player error
ended - Playback ended
timeupdate number Time update (current time)
pause number Paused (current time)
play number Playing (current time)
fullscreen boolean Fullscreen state changed
snapOutside string External snapshot (base64)
snapInside string Internal snapshot (base64)
customButtons string Custom button clicked
canplay number Can play (duration in seconds)
volumechange { volume: number, muted: boolean } Volume changed
ready any Player ready
recordingStart - Recording started
recordingStop - Recording stopped
recordingError string Recording error

Methods

Playback Control

  • play() - Start playback
  • pause() - Pause playback
  • togglePlay() - Toggle play/pause
  • paused() - Check if paused
  • getCurrentTime() - Get current time
  • setCurrentTime(time: number) - Set current time
  • getDuration() - Get video duration

Volume Control

  • getMuted() - Check if muted
  • setMuted(muted: boolean) - Set muted state
  • toggleMute() - Toggle mute
  • getVolume() - Get volume (0-1)
  • setVolume(volume: number) - Set volume

Fullscreen Control

  • isFullscreen() - Check fullscreen state
  • requestFullscreen() - Enter fullscreen
  • exitFullscreen() - Exit fullscreen
  • toggleFullscreen() - Toggle fullscreen

Recording

  • startRecording() - Start recording
  • stopRecording() - Stop recording
  • toggleRecording() - Toggle recording
  • isRecording() - Check recording state
  • getRecordingTime() - Get recording duration
  • forceStopRecording() - Force stop recording
  • recoverFromRecordingError() - Recover from error

Playback Switch

  • togglePlayback() - Toggle video on/off
  • isPlaying() - Check if video is playing

Other

  • snap() - Take screenshot
  • getPlayer() - Get player instance

Example

<template>
  <div class="video-container">
    <LivePlayerWrapper
      ref="playerRef"
      :video-url="streamUrl"
      :video-title="streamTitle"
      :autoplay="true"
      :controls="true"
      :live="true"
      :muted="false"
      :aspect="'16:9'"
      :show-custom-button="true"
      :custom-buttons="'录制:vjs-icon-record,开关:vjs-icon-switch'"
      @ready="onPlayerReady"
      @recordingStart="onRecordingStart"
      @recordingStop="onRecordingStop"
      @recordingError="onRecordingError"
      @customButtons="onCustomButtonClick"
    />
    
    <div class="controls">
      <button @click="startRecording">Start Recording</button>
      <button @click="stopRecording">Stop Recording</button>
      <button @click="togglePlayback">Toggle Playback</button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { LivePlayerWrapper } from 'liveplayer-wrapper'

const playerRef = ref()
const streamUrl = ref('https://example.com/live.m3u8')
const streamTitle = ref('Live Stream')

const onPlayerReady = (player: any) => {
  console.log('Player ready:', player)
}

const onRecordingStart = () => {
  console.log('Recording started')
}

const onRecordingStop = () => {
  console.log('Recording stopped')
}

const onRecordingError = (error: string) => {
  console.error('Recording error:', error)
}

const onCustomButtonClick = (buttonName: string) => {
  console.log('Custom button clicked:', buttonName)
}

const startRecording = () => {
  playerRef.value?.startRecording()
}

const stopRecording = () => {
  playerRef.value?.stopRecording()
}

const togglePlayback = () => {
  playerRef.value?.togglePlayback()
}
</script>

<style scoped>
.video-container {
  max-width: 800px;
  margin: 0 auto;
}

.controls {
  margin-top: 20px;
  text-align: center;
}

.controls button {
  margin: 0 10px;
  padding: 10px 20px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.controls button:hover {
  background: #0056b3;
}
</style>

Development

# Install dependencies
npm install

# Start development server
npm run dev

# Build library
npm run build:lib

# Build example
npm run build

License

MIT