1.0.9 • Published 5 years ago

react-flv-player v1.0.9

Weekly downloads
107
License
MIT
Repository
github
Last release
5 years ago

Installation

npm i react-flv-player

Usage

import React, { Component } from 'react';
import {ReactFlvPlayer} from 'react-flv-player'

class Index extends Component {

  render() {
    return (
      <div>
        <ReactFlvPlayer
          url = "http://xxx/xxx/xxx.flv"
          heigh = "800px"
          width = "800px"
          isMuted={true}
        />
      </div>
    );
  }
}

export default Index;

image

Props

FieldTypeDefaultDescription
typestringflvIndicates media type, 'flv' or 'mp4'
isLive?booleantrueIndicates whether the data source is a live stream
hasAudio?booleantrueIndicates whether the stream has audio track
hasVideo?booleantrueIndicates whether the stream has video track
url?stringurlIndicates media URL, can be starts with 'https(s)' or 'ws(s)' (WebSocket)
enableStashBuffer?booleantrueEnable IO stash buffer. Set to false if you need realtime (minimal latency) for live stream
stashInitialSize?number128 (KB)Indicates IO stash buffer initial size. Default is 384KB. Indicate a suitable size can improve video load/seek time.
height?px or %100%
width?px or %100%
isMuted?booleanrequiredIndicates audio output when init the video
handleError?function(err)=>{console.log(err)}Handle errors, error type is enum
enableWarning?booleanfalseEnable Warnings in Console
enableError?booleanfalseEnable errors in Console

Errors

<ReactFlvPlayer
  url={videoUrl}
  isMuted
  handleError={(err) => {
  switch (err) {
    case 'NetworkError':
      // todo
      console.log('network error');
    break;
    case 'MediaError':
      console.log('network error');
    break;
    default:
      console.log('other error');
  }
}}
/>
ErrorDescription
NETWORK_ERRORErrors related to the network
MEDIA_ERRORErrors related to the media (format error, decode issue, etc)
OTHER_ERRORAny other unspecified error