Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mr-julyedu
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
baiguangyao
mr-julyedu
Commits
36e22dc8
Commit
36e22dc8
authored
Sep 26, 2019
by
wangshuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
学习进度一部分
parent
18d56a56
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
5 deletions
+26
-5
src/components/video/index.js
+26
-5
No files found.
src/components/video/index.js
View file @
36e22dc8
...
@@ -80,6 +80,8 @@ class Video extends Component {
...
@@ -80,6 +80,8 @@ class Video extends Component {
recordSocket
recordSocket
recordTimer
recordTimer
isCurrentVideoFirstPlay
=
true
state
=
{
state
=
{
title
:
''
,
title
:
''
,
...
@@ -341,21 +343,23 @@ class Video extends Component {
...
@@ -341,21 +343,23 @@ class Video extends Component {
forceNew
:
true
forceNew
:
true
})
})
// this.recordSocket = io(API.record)
// this.recordSocket = io(API.record)
this
.
recordSocket
.
on
(
'seek'
,
time
=>
{
//
this.recordSocket.on('seek', time => {
this
.
player
.
currentTime
(
time
)
//
this.player.currentTime(time)
})
//
})
// 开启定时器 每5秒发送一次学习记录 --删除
this
.
recordTimer
=
setInterval
(()
=>
{
this
.
recordTimer
=
setInterval
(()
=>
{
this
.
sendRecord
()
this
.
sendRecord
()
},
5000
)
},
5000
)
}
}
// 发送学习记录
sendRecord
=
()
=>
{
sendRecord
=
()
=>
{
if
(
this
.
recordSocket
&&
this
.
player
)
{
if
(
this
.
recordSocket
&&
this
.
player
)
{
this
.
recordSocket
.
emit
(
'addRecord'
,
this
.
recordUserInfo
())
this
.
recordSocket
.
emit
(
'addRecord'
,
this
.
recordUserInfo
())
}
}
}
}
// 返回学习记录的数据
recordUserInfo
=
()
=>
{
recordUserInfo
=
()
=>
{
let
{
uid
}
=
this
.
props
.
user
.
data
let
{
uid
}
=
this
.
props
.
user
.
data
return
{
return
{
...
@@ -500,6 +504,7 @@ class Video extends Component {
...
@@ -500,6 +504,7 @@ class Video extends Component {
}
}
// 初始化视频播放器
initializePlayer
=
()
=>
{
initializePlayer
=
()
=>
{
window
.
HELP_IMPROVE_VIDEOJS
=
false
;
window
.
HELP_IMPROVE_VIDEOJS
=
false
;
this
.
player
=
videojs
(
this
.
video
,
{
this
.
player
=
videojs
(
this
.
video
,
{
...
@@ -518,6 +523,22 @@ class Video extends Component {
...
@@ -518,6 +523,22 @@ class Video extends Component {
this
.
player
.
on
(
'ready'
,
()
=>
{
this
.
player
.
on
(
'ready'
,
()
=>
{
this
.
recordSocket
.
emit
(
'load'
,
this
.
recordUserInfo
())
this
.
recordSocket
.
emit
(
'load'
,
this
.
recordUserInfo
())
})
})
this
.
player
.
on
(
'play'
,
()
=>
{
// 当视频播放时 看是否是第一次播放(初次进入页面 刷新页面 切换视频 都是第一次播放 需要获取上次的播放时间)
if
(
this
.
isCurrentVideoFirstPlay
)
{
this
.
ws
.
send
(
JSON
.
stringify
({
mtype
:
'recent_learn'
,
uid
:
this
.
props
.
user
.
data
.
uid
,
token
:
this
.
token
,
platform
:
5
,
video_id
:
videoList
[
activeIndex
][
'id'
],
course_id
:
this
.
state
.
courseId
,
v_course_id
:
vCourseId
,
}))
// 当某些原因导致视频暂停时(用户暂停 网络不好等) 再播放时不需要发送
this
.
isCurrentVideoFirstPlay
=
false
;
}
})
this
.
player
.
on
(
'ratechange'
,
()
=>
{
this
.
player
.
on
(
'ratechange'
,
()
=>
{
this
.
currentPlaybackRate
=
this
.
player
.
playbackRate
()
this
.
currentPlaybackRate
=
this
.
player
.
playbackRate
()
this
.
sendWatchTime
(
this
.
watchSec
,
this
.
previousPlaybackRate
)
this
.
sendWatchTime
(
this
.
watchSec
,
this
.
previousPlaybackRate
)
...
@@ -558,6 +579,7 @@ class Video extends Component {
...
@@ -558,6 +579,7 @@ class Video extends Component {
this
.
recordSocket
=
null
this
.
recordSocket
=
null
}
}
// 选择新的视频
selectVideo
=
index
=>
{
selectVideo
=
index
=>
{
if
(
index
===
this
.
state
.
activeIndex
)
{
if
(
index
===
this
.
state
.
activeIndex
)
{
return
return
...
@@ -625,7 +647,6 @@ class Video extends Component {
...
@@ -625,7 +647,6 @@ class Video extends Component {
let
_this
=
this
;
let
_this
=
this
;
this
.
setupWS
();
this
.
setupWS
();
this
.
setupTimer
();
this
.
setupTimer
();
console
.
log
(
'playSetup'
);
let
scheduleTime
=
setTimeout
(
function
()
{
let
scheduleTime
=
setTimeout
(
function
()
{
clearTimeout
(
scheduleTime
);
clearTimeout
(
scheduleTime
);
scheduleTime
=
null
;
scheduleTime
=
null
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment