Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
ydLife
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sweet Zhang
ydLife
Commits
455eb3a6
Commit
455eb3a6
authored
Jun 01, 2022
by
Sweet Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
视频播放监测优化
parent
24cd76af
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletions
+4
-1
src/app/common/video/video.component.ts
+4
-1
No files found.
src/app/common/video/video.component.ts
View file @
455eb3a6
...
...
@@ -38,10 +38,12 @@ export class VideoComponent implements OnInit, AfterViewInit, OnDestroy {
this
.
video
.
nativeElement
.
addEventListener
(
'pause'
,
()
=>
{
//暂停开始执行的函数
clearInterval
(
this
.
timer
);
clearInterval
(
this
.
timer2
);
console
.
log
(
'暂停播放'
)
this
.
saveVideoPlayback
();
});
this
.
video
.
nativeElement
.
addEventListener
(
'play'
,
()
=>
{
//开始执行的函数
this
.
timer
=
setInterval
(()
=>
{
console
.
log
(
'开始播放'
)
this
.
saveVideoPlayback
();
},
1000
*
20
)
this
.
queryVideoPlayback
(
2
)
...
...
@@ -97,8 +99,9 @@ export class VideoComponent implements OnInit, AfterViewInit, OnDestroy {
this
.
maxViewTime
=
this
.
videoPlaybacks
[
0
][
'maxViewTime'
];
if
(
type
===
1
){
// 设置开始播放时间为上次离开时间
this
.
video
.
nativeElement
.
currentTime
=
this
.
videoPlaybacks
.
length
>
0
?
this
.
videoPlaybacks
[
0
][
'viewTime'
]
:
0
;
this
.
originTime
=
this
.
video
.
nativeElement
.
currentTime
=
this
.
videoPlaybacks
.
length
>
0
?
this
.
videoPlaybacks
[
0
][
'viewTime'
]
:
0
;
}
else
{
// 监测有没有拖动进度条
this
.
timer2
=
setInterval
(()
=>
{
if
(
this
.
video
.
nativeElement
.
currentTime
-
this
.
originTime
>
1
&&
this
.
video
.
nativeElement
.
currentTime
>
this
.
maxViewTime
)
{
this
.
video
.
nativeElement
.
currentTime
=
this
.
originTime
;
...
...
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