parent
9ecff11e57
commit
d87061bd00
@ -0,0 +1,37 @@
|
|||||||
|
import React, { useEffect, useRef } from 'react'
|
||||||
|
import Flv from 'flv.js'
|
||||||
|
|
||||||
|
export default ({ url }) => {
|
||||||
|
const ref = useRef()
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let player = null
|
||||||
|
if (Flv.isSupported) {
|
||||||
|
player = Flv.createPlayer({
|
||||||
|
type: 'flv',
|
||||||
|
volume: 0.8,
|
||||||
|
url,
|
||||||
|
muted: false
|
||||||
|
})
|
||||||
|
|
||||||
|
if (ref.current) {
|
||||||
|
player.attachMediaElement(ref.current)
|
||||||
|
player.load()
|
||||||
|
player.play()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return () => {
|
||||||
|
if (player) {
|
||||||
|
player.unload()
|
||||||
|
player.pause()
|
||||||
|
player.destroy()
|
||||||
|
player = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}, [url, ref.current])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<video ref={ref} controls autoPlay={true} muted={false} className="flv-player"></video>
|
||||||
|
)
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
@ -1,5 +1,5 @@
|
|||||||
import React, { Fragment } from 'react'
|
import React, { Fragment } from 'react'
|
||||||
import { ReactFlvPlayer } from 'react-flv-player'
|
import ReactFlvPlayer from './flv-player'
|
||||||
|
|
||||||
export default ({ src }) => {
|
export default ({ src }) => {
|
||||||
const suf = src.split('.').pop()
|
const suf = src.split('.').pop()
|
Loading…
Reference in new issue