巴林闲侠
2 years ago
6 changed files with 12419 additions and 1 deletions
@ -0,0 +1,71 @@ |
|||||
|
import React, { useEffect, useState, useRef } from 'react' |
||||
|
import { push } from 'react-router-redux'; |
||||
|
import { connect } from 'react-redux'; |
||||
|
import flvjs from 'flv.js' |
||||
|
import { getVideo } from '../actions' |
||||
|
import { Modal } from 'antd' |
||||
|
|
||||
|
const VideoModal = ({ dispatch, onCancel }) => { |
||||
|
const [video, setVideo] = useState({}) |
||||
|
const flvPlayer = useRef() |
||||
|
|
||||
|
useEffect(() => { |
||||
|
dispatch(getVideo()).then(res => { |
||||
|
console.log(res); |
||||
|
if (res.success) { |
||||
|
setVideo(res.payload.data) |
||||
|
const container = document.getElementById('video-play'); |
||||
|
const flv = flvjs.createPlayer({ |
||||
|
type: 'flv', |
||||
|
url: `${res.payload.data.ws_flv}`, |
||||
|
isLive: true, |
||||
|
hasAudio: false, |
||||
|
hasVideo: true, |
||||
|
}, { |
||||
|
enableWorker: false, |
||||
|
enalleStashBuffer: true, |
||||
|
stashInitialSize: 128, |
||||
|
lazyLoadMaxDuration: 3 * 60, |
||||
|
seekType: 'range', |
||||
|
autoCleanupSourceBuffer: true, |
||||
|
cors: true, |
||||
|
}); |
||||
|
flv.attachMediaElement(container); |
||||
|
flv.load(); |
||||
|
flv.play(); |
||||
|
flvPlayer.current = flv |
||||
|
} |
||||
|
}) |
||||
|
}, []) |
||||
|
|
||||
|
return ( |
||||
|
<Modal |
||||
|
title="监控视频" |
||||
|
open={true} |
||||
|
onOk={() => { }} |
||||
|
onCancel={() => { |
||||
|
onCancel() |
||||
|
}} |
||||
|
width={'64%'} |
||||
|
style={{}} |
||||
|
footer={null} |
||||
|
> |
||||
|
<video |
||||
|
id={'video-play'} |
||||
|
autoPlay muted controls |
||||
|
style={{ height: '100%', width: '100%', }} |
||||
|
> |
||||
|
|
||||
|
</video> |
||||
|
</Modal> |
||||
|
) |
||||
|
} |
||||
|
|
||||
|
function mapStateToProps (state) { |
||||
|
const { crane } = state; |
||||
|
return { |
||||
|
craneData: crane.data || {} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export default connect(mapStateToProps)(VideoModal); |
File diff suppressed because it is too large
Loading…
Reference in new issue