Giter VIP home page Giter VIP logo

flv-player-react's Introduction

FLV Player for React

A React component to play flv streaming video.

Installation

npm i flv-player-react --save

Usage

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

class Index extends Component {

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

export default Index;

Props

Field Type Default Description
type string flv Indicates media type, 'flv' or 'mp4'
isLive? boolean true Indicates whether the data source is a live stream
hasAudio? boolean true Indicates whether the stream has audio track
hasVideo? boolean true Indicates whether the stream has video track
url? string url Indicates media URL, can be starts with 'https(s)' or 'ws(s)' (WebSocket)
enableStashBuffer? boolean true Enable IO stash buffer. Set to false if you need realtime (minimal latency) for live stream
stashInitialSize? number 128 (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? boolean required Indicates audio output when init the video
handleError? function (err)=>{console.log(err)} Handle errors, error type is enum
enableWarning? boolean false Enable Warnings in Console
enableError? boolean false Enable 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');
  }
}}
/>
Error Description
NETWORK_ERROR Errors related to the network
MEDIA_ERROR Errors related to the media (format error, decode issue, etc)
OTHER_ERROR Any other unspecified error

flv-player-react's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.