Merge branch 'master' of http://10.10.14.176:3000/web/syzx
commit
85a69b1408
@ -1,40 +1,68 @@
|
||||
import React from "react";
|
||||
import React, {useEffect,useState} from "react";
|
||||
import videojs from "video.js";
|
||||
import "video.js/dist/video-js.css";
|
||||
import "videojs-contrib-hls";
|
||||
export const VideoJS = ( props: any ) => {
|
||||
|
||||
const [count,setCount]=useState(0);
|
||||
const countRef=React.useRef(count);
|
||||
const videoRef = React.useRef(null);
|
||||
const playerRef = React.useRef<any>(null);
|
||||
const { options, onReady } = props;
|
||||
|
||||
const { options, onReady,saveLearning,getTime } = props;
|
||||
React.useEffect(() => {
|
||||
|
||||
// make sure Video.js player is only initialized once
|
||||
if (!playerRef.current) {
|
||||
const videoElement = videoRef.current;
|
||||
if (!videoElement) return;
|
||||
|
||||
const player = playerRef.current = videojs(videoElement, options, () => {
|
||||
console.log("player is ready");
|
||||
// console.log("player is ready");
|
||||
onReady && onReady(player);
|
||||
});
|
||||
} else {
|
||||
// you can update player here [update player through props]
|
||||
const player = playerRef.current;
|
||||
console.log('playerplayerplayer===',player);
|
||||
player.src(options.sources[0].src);
|
||||
player.autoplay(true);
|
||||
|
||||
player.src(options.sources[0].src);
|
||||
// player.autoplay(true);
|
||||
videoRef.current.addEventListener('play',()=>{
|
||||
console.log('播放');
|
||||
setCount(player.currentTime());
|
||||
playerRef.current.currentTime(count)
|
||||
// player.currentTime(count)
|
||||
// getTime(player.currentTime());
|
||||
// saveLearning();
|
||||
});
|
||||
videoRef.current.addEventListener('pause',()=>{
|
||||
console.log('停止了')
|
||||
})
|
||||
|
||||
}
|
||||
}, [options, videoRef]);
|
||||
|
||||
|
||||
}, [options]);
|
||||
// useEffect(()=>{
|
||||
// videoRef.current.addEventListener()
|
||||
// },[]);
|
||||
|
||||
React.useEffect(()=>{
|
||||
countRef.current=count;
|
||||
},[count])
|
||||
|
||||
|
||||
if(count!==0){
|
||||
if(countRef.current.toFixed(2)!==count.toFixed(2)){
|
||||
// console.log('countRef.current前一次',countRef.current.toFixed(2));
|
||||
// console.log('count这一次',count.toFixed(2))
|
||||
getTime(count.toFixed(2));
|
||||
saveLearning(count);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<div data-vjs-player>
|
||||
<video style={{
|
||||
width:'100%',
|
||||
height:'auto'
|
||||
|
||||
}} ref={videoRef} className="video-js vjs-big-play-centered" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,43 @@
|
||||
import { request } from 'umi';
|
||||
import type { CardListItemDataType } from './data.d';
|
||||
|
||||
export async function queryFakeList(params: {
|
||||
count: number;
|
||||
}): Promise<{ data: { list: CardListItemDataType[] } }> {
|
||||
return request('/api/card_fake_list', {
|
||||
// export async function queryFakeList(params: {
|
||||
// count: number;
|
||||
// }): Promise<{ data: { list: CardListItemDataType[] } }> {
|
||||
// return request('/api/card_fake_list', {
|
||||
// params,
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
//获取课节
|
||||
export async function listMyLearningChapterCourse1(params: {
|
||||
chapter_id: number;
|
||||
identity_id: number;
|
||||
person_id: number;
|
||||
subject_id: number
|
||||
}){
|
||||
return request(' /dsideal_yy/ypt/careerTraining/learning/listMyLearningChapterCourse', {
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export async function viewCourseGetMyLearning(data: { [key: string]: any }, options?: { [key: string]: any }) {
|
||||
return request('/dsideal_yy/ypt/careerTraining/learning/viewCourseGetMyLearning', {
|
||||
data,
|
||||
method: 'POST',
|
||||
requestType: "form",
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
//保存进度
|
||||
export async function saveMyLearning(data: { [key: string]: any }, options?: { [key: string]: any }) {
|
||||
return request('/dsideal_yy/ypt/careerTraining/learning/saveMyLearning', {
|
||||
data,
|
||||
method: 'POST',
|
||||
requestType: "form",
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in new issue