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
c2868e6f
Commit
c2868e6f
authored
Sep 10, 2019
by
wangshuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
播放页学习进度
parent
7e26dc24
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
4 deletions
+37
-4
src/components/video/index.js
+37
-4
No files found.
src/components/video/index.js
View file @
c2868e6f
...
@@ -75,6 +75,7 @@ class Video extends Component {
...
@@ -75,6 +75,7 @@ class Video extends Component {
previousPlaybackRate
=
1
previousPlaybackRate
=
1
currentPlaybackRate
=
1
currentPlaybackRate
=
1
reconnect
=
true
reconnect
=
true
timeEnough
=
false
recordSocket
recordSocket
recordTimer
recordTimer
...
@@ -381,12 +382,24 @@ class Video extends Component {
...
@@ -381,12 +382,24 @@ class Video extends Component {
})
})
this
.
ws
.
addEventListener
(
'message'
,
e
=>
{
this
.
ws
.
addEventListener
(
'message'
,
e
=>
{
const
data
=
JSON
.
parse
(
e
.
data
);
const
data
=
JSON
.
parse
(
e
.
data
);
data
.
code
==
4040
&&
(
this
.
reconnect
=
false
)
data
.
code
==
4040
&&
(
this
.
reconnect
=
false
);
data
.
code
==
5001
&&
(
this
.
timeEnough
=
true
);
})
})
}
}
sendMessage
=
message
=>
{
sendMessage
=
message
=>
{
let
readyState
=
this
.
ws
.
readyState
,
_this
=
this
;
if
(
readyState
===
1
)
{
this
.
ws
&&
this
.
ws
.
send
(
JSON
.
stringify
(
message
))
this
.
ws
&&
this
.
ws
.
send
(
JSON
.
stringify
(
message
))
}
else
if
(
readyState
===
3
)
{
this
.
ws
.
close
();
this
.
ws
=
null
;
let
reconnect
=
setTimeout
(
function
()
{
clearTimeout
(
reconnect
);
reconnect
=
null
;
_this
.
ws
=
new
WebSocket
(
PROCESS_URL
);
},
500
);
}
}
}
//视频结束请求接口
//视频结束请求接口
...
@@ -407,6 +420,11 @@ class Video extends Component {
...
@@ -407,6 +420,11 @@ class Video extends Component {
console
.
log
(
'免费课程 拦截'
);
console
.
log
(
'免费课程 拦截'
);
return
;
return
;
}
}
// 时间足够不发送
if
(
this
.
timeEnough
)
{
console
.
log
(
'5001 时间足够'
);
return
;
}
if
(
course
.
is_aist
)
{
if
(
course
.
is_aist
)
{
// 返现课程
// 返现课程
this
.
sendMessage
({
this
.
sendMessage
({
...
@@ -441,6 +459,11 @@ class Video extends Component {
...
@@ -441,6 +459,11 @@ class Video extends Component {
if
(
Number
(
sec
)
===
0
)
{
if
(
Number
(
sec
)
===
0
)
{
return
;
return
;
}
}
// 时间足够不发送
if
(
this
.
timeEnough
)
{
console
.
log
(
'5001 时间足够'
);
return
;
}
let
info_type
=
'c_watch_time'
;
let
info_type
=
'c_watch_time'
;
if
(
course
.
is_aist
)
{
if
(
course
.
is_aist
)
{
info_type
=
'watch_time'
;
info_type
=
'watch_time'
;
...
@@ -454,7 +477,7 @@ class Video extends Component {
...
@@ -454,7 +477,7 @@ class Video extends Component {
v_course_id
:
vCourseId
,
v_course_id
:
vCourseId
,
uid
:
this
.
props
.
user
.
data
.
uid
,
uid
:
this
.
props
.
user
.
data
.
uid
,
token
:
this
.
token
,
token
:
this
.
token
,
platform
:
0
platform
:
5
})
})
}
}
...
@@ -501,9 +524,13 @@ class Video extends Component {
...
@@ -501,9 +524,13 @@ class Video extends Component {
this
.
previousPlaybackRate
=
this
.
currentPlaybackRate
this
.
previousPlaybackRate
=
this
.
currentPlaybackRate
})
})
this
.
player
.
on
(
'ended'
,
()
=>
{
this
.
player
.
on
(
'ended'
,
()
=>
{
console
.
log
(
'ended'
);
this
.
sendWatchTime
(
this
.
watchSec
,
this
.
currentPlaybackRate
)
this
.
sendWatchTime
(
this
.
watchSec
,
this
.
currentPlaybackRate
)
this
.
countSchedule
();
// 计算进度
this
.
countSchedule
();
// 计算进度
// 返现课程才出现打卡记录
if
(
this
.
state
.
course
.
is_aist
)
{
this
.
getShareProgressInfo
()
this
.
getShareProgressInfo
()
}
clearInterval
(
this
.
timer
)
clearInterval
(
this
.
timer
)
})
})
this
.
player
.
on
(
'seeked'
,
()
=>
{
this
.
player
.
on
(
'seeked'
,
()
=>
{
...
@@ -534,7 +561,7 @@ class Video extends Component {
...
@@ -534,7 +561,7 @@ class Video extends Component {
if
(
index
===
this
.
state
.
activeIndex
)
{
if
(
index
===
this
.
state
.
activeIndex
)
{
return
return
}
}
console
.
log
(
'selectVideo'
);
this
.
countSchedule
();
// 计算进度
this
.
countSchedule
();
// 计算进度
this
.
setState
(
this
.
setState
(
...
@@ -592,9 +619,15 @@ class Video extends Component {
...
@@ -592,9 +619,15 @@ class Video extends Component {
if
(
Number
(
course
.
course_id
)
===
0
||
course
.
course_id
===
''
)
{
if
(
Number
(
course
.
course_id
)
===
0
||
course
.
course_id
===
''
)
{
console
.
log
(
'免费课程 拦截'
);
console
.
log
(
'免费课程 拦截'
);
}
else
{
}
else
{
let
_this
=
this
;
this
.
setupWS
();
this
.
setupWS
();
this
.
setupTimer
();
this
.
setupTimer
();
this
.
countSchedule
();
console
.
log
(
'playSetup'
);
let
scheduleTime
=
setTimeout
(
function
()
{
clearTimeout
(
scheduleTime
);
scheduleTime
=
null
;
_this
.
countSchedule
();
},
1000
);
}
}
let
index
=
this
.
getLastVideoIndex
(
course
.
last_video_id
);
let
index
=
this
.
getLastVideoIndex
(
course
.
last_video_id
);
index
=
index
>=
0
?
index
:
0
;
index
=
index
>=
0
?
index
:
0
;
...
...
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