Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_chen
commit
bcdc47879a
@ -1,37 +0,0 @@
|
||||
import React, { useEffect, useRef } from 'react'
|
||||
|
||||
export default ({ url }) => {
|
||||
const ref = useRef()
|
||||
|
||||
useEffect(() => {
|
||||
let player = null
|
||||
if (window.flvjs.isSupported) {
|
||||
player = window.flvjs.createPlayer({
|
||||
type: 'flv',
|
||||
volume: 0.8,
|
||||
cors: true,
|
||||
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>
|
||||
)
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
import axios from 'axios'
|
||||
|
||||
export async function logWatchHistory(params) {
|
||||
try {
|
||||
const response = await axios.post('/watch_video_histories.json', params)
|
||||
return response.data.log_id
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
return 0
|
||||
}
|
Loading…
Reference in new issue