Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
P
pica-professional-exam
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
Close sidebar
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Culm
pica-professional-exam
提交
cb0609c7
提交
cb0609c7
编写于
8月 18, 2020
作者:
guofeng.chen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改视频
上级
3ab45d93
变更
4
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
197 行增加
和
76 行删除
+197
-76
pica-video.vue
src/components/course/pica-video.vue
+177
-76
screen_full.png
src/images/video/screen_full.png
+0
-0
screen_mini.png
src/images/video/screen_mini.png
+0
-0
common.scss
src/style/common.scss
+20
-0
未找到文件。
src/components/course/pica-video.vue
浏览文件 @
cb0609c7
...
@@ -9,7 +9,9 @@
...
@@ -9,7 +9,9 @@
preload
preload
webkit-playsinline
webkit-playsinline
playsinline
playsinline
x-webkit-airplay=
"allow"
x5-video-player-type=
"h5"
x5-video-player-type=
"h5"
x5-video-player-fullscreen=
"true"
mtt-playsinline=
"true"
mtt-playsinline=
"true"
@
loadedmetadata=
"loadedMetaData"
@
loadedmetadata=
"loadedMetaData"
@
timeupdate=
"onTimeUpdate"
@
timeupdate=
"onTimeUpdate"
...
@@ -26,9 +28,26 @@
...
@@ -26,9 +28,26 @@
<div
class=
"progress-inner"
>
<div
class=
"progress-inner"
>
<div
class=
"progress-bar"
:style=
"progressBar"
></div>
<div
class=
"progress-bar"
:style=
"progressBar"
></div>
</div>
</div>
<div
class=
"progress-ball"
:style=
"
{left: `${progressBall}%`}"
@touchstart.stop="onBallStart"
@touchmove.stop="onBallMove"
@touchend.stop="onBallEnd">
</div>
</div>
</div>
<div
class=
"time-box"
>
{{
playTime
}}
/
{{
totalTime
}}
</div>
<div
class=
"time-box"
>
{{
playTime
}}
/
{{
totalTime
}}
</div>
<div
class=
"bar-empty"
></div>
<div
class=
"rate-box"
@
click=
"showRate=true"
>
倍速
<div
class=
"rate-list"
v-show=
"showRate"
>
<div
class=
"rate-item"
:class=
"
{'rate-active': rate === curtRate}"
v-for="rate in rates"
:key="rate"
@click.stop="selectRate(rate)">
{{
rate
}}
</div>
</div>
</div>
<div
class=
"btn-screen"
:class=
"
{'btn-screen-mini': isFullScreen}" @click="onFullscreen">
</div>
<div
class=
"btn-screen"
:class=
"
{'btn-screen-mini': isFullScreen}" @click="onFullscreen">
</div>
</div>
</div>
</div>
</div>
...
@@ -86,9 +105,13 @@ export default {
...
@@ -86,9 +105,13 @@ export default {
vid
:
''
,
// 唯一id
vid
:
''
,
// 唯一id
playTime
:
'00:00'
,
// 播放时长
playTime
:
'00:00'
,
// 播放时长
totalTime
:
'00:00'
,
// 总时长
totalTime
:
'00:00'
,
// 总时长
isPaused
:
fals
e
,
// 是否暂停
isPaused
:
tru
e
,
// 是否暂停
isFullScreen
:
false
,
// 是否全屏
isFullScreen
:
false
,
// 是否全屏
progressBar
:
{
}
,
// 进度条
progressBar
:
{
}
,
// 进度条
progressBall
:
0
,
// 进度球
rates
:
[
2
,
1.5
,
1
,
0.5
],
curtRate
:
1
,
showRate
:
false
,
showProved
:
false
,
// 试看提示文字
showProved
:
false
,
// 试看提示文字
showError
:
false
,
// 播放错误
showError
:
false
,
// 播放错误
showResume
:
false
,
// 继续播放
showResume
:
false
,
// 继续播放
...
@@ -105,6 +128,7 @@ export default {
...
@@ -105,6 +128,7 @@ export default {
mounted
()
{
mounted
()
{
const
player
=
document
.
getElementById
(
this
.
vid
);
const
player
=
document
.
getElementById
(
this
.
vid
);
player
.
addEventListener
(
"timeupdate"
,
this
.
onTimeUpdate
,
false
);
player
.
addEventListener
(
"timeupdate"
,
this
.
onTimeUpdate
,
false
);
this
.
player
=
player
;
}
,
}
,
beforeDestroy
()
{
beforeDestroy
()
{
this
.
timer
&&
clearTimeout
(
this
.
timer
);
this
.
timer
&&
clearTimeout
(
this
.
timer
);
...
@@ -117,34 +141,31 @@ export default {
...
@@ -117,34 +141,31 @@ export default {
}
,
}
,
methods
:
{
methods
:
{
togglePlay
()
{
togglePlay
()
{
if
(
!
this
.
logged
)
{
//
if (!this.logged)
{
this
.
$store
.
dispatch
(
'goLogin'
);
//
this.$store.dispatch('goLogin');
return
;
//
return;
}
//
}
if
(
!
this
.
url
||
!
this
.
loaded
||
!
this
.
enable
)
{
if
(
!
this
.
url
||
!
this
.
enable
)
{
return
;
return
;
}
}
let
isPaused
=
this
.
isPaused
;
let
isPaused
=
this
.
isPaused
;
const
player
=
document
.
getElementById
(
this
.
vid
);
// 试看,且超过时间
// 试看,且超过时间
if
(
this
.
proved
&&
player
.
currentTime
>=
this
.
proved
)
{
if
(
this
.
proved
&&
this
.
player
.
currentTime
>=
this
.
proved
)
{
return
;
return
;
}
}
if
(
isPaused
)
{
if
(
isPaused
)
{
this
.
commonBuriedData
(
`984#984001`
);
this
.
player
.
play
();
player
.
play
();
}
else
{
}
else
{
player
.
pause
();
this
.
player
.
pause
();
}
}
this
.
reportOnOff
(
isPaused
?
1
:
2
);
//
this.reportOnOff(isPaused ? 1 : 2);
this
.
isPaused
=
!
isPaused
;
this
.
isPaused
=
!
isPaused
;
}
,
}
,
// 切换视频
// 切换视频
switchUrl
(
opts
=
{
}
)
{
switchUrl
(
opts
=
{
}
)
{
const
{
url
=
''
,
poster
=
''
,
proved
=
0
,
history
=
0
,
enable
=
true
}
=
opts
;
const
{
url
=
''
,
poster
=
''
,
proved
=
0
,
history
=
0
,
enable
=
true
}
=
opts
;
const
player
=
document
.
getElementById
(
this
.
vid
);
this
.
loaded
=
false
;
this
.
loaded
=
false
;
player
.
src
=
url
;
this
.
player
.
src
=
url
;
this
.
url
=
url
;
this
.
url
=
url
;
this
.
poster
=
poster
;
this
.
poster
=
poster
;
this
.
proved
=
proved
;
this
.
proved
=
proved
;
...
@@ -157,7 +178,6 @@ export default {
...
@@ -157,7 +178,6 @@ export default {
this
.
currentTime
=
null
;
this
.
currentTime
=
null
;
this
.
duration
=
null
;
this
.
duration
=
null
;
if
(
this
.
showError
)
this
.
showError
=
false
;
if
(
this
.
showError
)
this
.
showError
=
false
;
return
player
;
}
,
}
,
// 切换并播放
// 切换并播放
switchUrlAndPlay
(
opts
=
{
}
)
{
switchUrlAndPlay
(
opts
=
{
}
)
{
...
@@ -165,13 +185,13 @@ export default {
...
@@ -165,13 +185,13 @@ export default {
this
.
reportOnOff
(
2
);
this
.
reportOnOff
(
2
);
}
}
this
.
reportLeave
();
this
.
reportLeave
();
const
player
=
this
.
switchUrl
(
opts
);
this
.
switchUrl
(
opts
);
if
(
!
this
.
enable
)
{
if
(
!
this
.
enable
)
{
return
;
return
;
}
}
const
loop
=
()
=>
{
const
loop
=
()
=>
{
if
(
this
.
loaded
)
{
if
(
this
.
loaded
)
{
player
.
play
();
this
.
player
.
play
();
this
.
isPaused
=
false
;
this
.
isPaused
=
false
;
this
.
reportOnOff
(
1
);
this
.
reportOnOff
(
1
);
return
null
;
return
null
;
...
@@ -183,18 +203,20 @@ export default {
...
@@ -183,18 +203,20 @@ export default {
}
}
this
.
timer
=
loop
();
this
.
timer
=
loop
();
}
,
}
,
// 加载完毕,获取总时长和音量
// 加载完毕,获取总时长和音量。问题:移动端点击播放才会触发,且不一定会获取时长
loadedMetaData
(
e
)
{
loadedMetaData
()
{
let
{
duration
}
=
e
.
target
;
let
duration
=
this
.
player
.
duration
;
if
(
duration
)
{
this
.
totalTime
=
this
.
formatTime
(
duration
);
this
.
totalTime
=
this
.
formatTime
(
duration
);
this
.
loaded
=
true
;
this
.
loaded
=
true
;
if
(
this
.
history
)
{
if
(
this
.
history
)
{
e
.
target
.
currentTime
=
this
.
history
;
this
.
player
.
currentTime
=
this
.
history
;
this
.
showResume
=
true
;
this
.
showResume
=
true
;
setTimeout
(()
=>
{
setTimeout
(()
=>
{
this
.
showResume
=
false
;
this
.
showResume
=
false
;
}
,
2000
);
}
,
2000
);
}
}
}
}
,
}
,
// 播放中
// 播放中
onTimeUpdate
(
e
)
{
onTimeUpdate
(
e
)
{
...
@@ -210,6 +232,9 @@ export default {
...
@@ -210,6 +232,9 @@ export default {
this
.
currentTime
=
currentTime
;
this
.
currentTime
=
currentTime
;
this
.
duration
=
duration
;
this
.
duration
=
duration
;
}
}
if
(
currentTime
<
0.1
&&
!
this
.
loaded
)
{
this
.
loadedMetaData
();
}
// 试看,且超过时间
// 试看,且超过时间
if
(
this
.
proved
&&
currentTime
>=
this
.
proved
)
{
if
(
this
.
proved
&&
currentTime
>=
this
.
proved
)
{
this
.
provedEnd
();
this
.
provedEnd
();
...
@@ -223,27 +248,70 @@ export default {
...
@@ -223,27 +248,70 @@ export default {
'-moz-transform'
:
`-moz-translateX(${percent
}
%)`
,
'-moz-transform'
:
`-moz-translateX(${percent
}
%)`
,
'-ms-transform'
:
`-ms-translateX(${percent
}
%)`
,
'-ms-transform'
:
`-ms-translateX(${percent
}
%)`
,
}
}
if
(
target
===
'progressBar'
&&
!
this
.
isMoveingBall
)
{
this
.
progressBall
=
percent
}
}
,
}
,
// 设置进度
//
点击
设置进度
setProgress
(
e
)
{
setProgress
(
e
)
{
if
(
!
this
.
url
||
!
this
.
loaded
)
{
if
(
!
this
.
url
)
{
return
;
return
;
}
}
const
{
offsetX
}
=
e
;
const
{
offsetX
}
=
e
;
const
{
width
}
=
e
.
target
.
getBoundingClientRect
();
const
{
width
}
=
e
.
target
.
getBoundingClientRect
();
const
player
=
document
.
getElementById
(
this
.
vid
);
this
.
setProgressPosition
(
offsetX
*
100
/
width
);
const
duration
=
player
.
duration
;
}
,
// 设置进度最终位置
setProgressPosition
(
percent
)
{
const
duration
=
this
.
player
.
duration
;
// 试看,且超过时间
// 试看,且超过时间
if
(
this
.
proved
&&
offsetX
/
width
>=
this
.
proved
/
duration
)
{
if
(
this
.
proved
&&
percent
>=
this
.
proved
*
100
/
duration
)
{
return
;
return
;
}
}
this
.
setBarPosition
(
offsetX
*
100
/
width
,
'progressBar'
);
this
.
setBarPosition
(
percent
,
'progressBar'
);
player
.
currentTime
=
offsetX
*
duration
/
width
;
this
.
player
.
currentTime
=
percent
*
duration
/
100
;
if
(
this
.
isPaused
)
{
if
(
this
.
isPaused
)
{
player
.
play
();
this
.
player
.
play
();
this
.
isPaused
=
false
;
this
.
isPaused
=
false
;
this
.
reportOnOff
(
1
);
// this.reportOnOff(1);
}
}
,
// 拖动进度条
onBallStart
(
e
)
{
this
.
isMoveingBall
=
true
;
const
{
width
}
=
this
.
$el
.
querySelector
(
'.progress-inner'
).
getBoundingClientRect
();
const
{
pageX
}
=
e
.
changedTouches
[
0
];
this
.
ballPageX
=
pageX
;
this
.
progressW
=
width
;
this
.
oldBallPercent
=
this
.
progressBall
;
}
,
onBallMove
(
e
)
{
const
{
pageX
}
=
e
.
changedTouches
[
0
];
this
.
progressBall
=
this
.
getNewPercent
(
pageX
);
}
,
onBallEnd
(
e
)
{
this
.
isMoveingBall
=
false
;
const
{
pageX
}
=
e
.
changedTouches
[
0
];
const
newPercent
=
this
.
getNewPercent
(
pageX
);
this
.
setProgressPosition
(
newPercent
);
}
,
// 获取拖动百分比
getNewPercent
(
pageX
)
{
let
newPercent
=
(
pageX
-
this
.
ballPageX
)
*
100
/
this
.
progressW
+
this
.
oldBallPercent
;
if
(
newPercent
<=
0
)
{
newPercent
=
0
}
else
if
(
newPercent
>=
100
)
{
newPercent
=
100
}
return
newPercent
;
}
,
selectRate
(
rate
)
{
if
(
!
this
.
url
)
{
return
;
}
}
this
.
player
.
playbackRate
=
rate
;
this
.
curtRate
=
rate
;
this
.
showRate
=
false
;
}
,
}
,
formatTime
(
t
)
{
formatTime
(
t
)
{
const
time
=
formatLeftTimeObj
(
t
);
const
time
=
formatLeftTimeObj
(
t
);
...
@@ -254,8 +322,7 @@ export default {
...
@@ -254,8 +322,7 @@ export default {
provedEnd
()
{
provedEnd
()
{
this
.
provedOver
=
true
;
this
.
provedOver
=
true
;
this
.
showProved
=
false
;
this
.
showProved
=
false
;
const
player
=
document
.
getElementById
(
this
.
vid
);
this
.
player
.
pause
();
player
.
pause
();
this
.
$emit
(
'onVideoEnd'
,
{
type
:
2
}
);
this
.
$emit
(
'onVideoEnd'
,
{
type
:
2
}
);
this
.
finish
=
true
;
this
.
finish
=
true
;
this
.
reportOnOff
(
2
);
this
.
reportOnOff
(
2
);
...
@@ -344,81 +411,115 @@ export default {
...
@@ -344,81 +411,115 @@ export default {
left
:
0
;
left
:
0
;
bottom
:
0
;
bottom
:
0
;
width
:
100
%
;
width
:
100
%
;
height
:
px2rem
(
44
px
)
;
height
:
44
px
;
}
}
.
control
-
bar
{
.
control
-
bar
{
position
:
absolute
;
position
:
absolute
;
display
:
flex
;
display
:
flex
;
align
-
items
:
center
;
align
-
items
:
center
;
justify
-
content
:
center
;
left
:
0
;
left
:
0
;
top
:
0
;
top
:
0
;
width
:
100
%
;
width
:
100
%
;
height
:
px2rem
(
44
px
)
;
height
:
44
px
;
// transform: translate3d(0, 60px, 0);
// transform: translate3d(0, 60px, 0);
// transition: transform 0.2s;
// transition: transform 0.2s;
background
:
linear
-
gradient
(
180
deg
,
rgba
(
0
,
0
,
0
,
0
)
0
%
,
rgba
(
0
,
0
,
0
,
1
)
100
%
);
background
:
linear
-
gradient
(
180
deg
,
rgba
(
0
,
0
,
0
,
0
)
0
%
,
rgba
(
0
,
0
,
0
,
1
)
100
%
);
}
}
.
btn
-
play
{
.
btn
-
play
{
width
:
px2rem
(
44
px
)
;
width
:
44
px
;
height
:
px2rem
(
44
px
)
;
height
:
44
px
;
background
-
image
:
url
(
'~@/images/video/play.png'
);
background
-
image
:
url
(
'~@/images/video/play.png'
);
background
-
repeat
:
no
-
repeat
;
background
-
repeat
:
no
-
repeat
;
background
-
position
:
50
%
50
%
;
background
-
position
:
50
%
50
%
;
background
-
size
:
px2rem
(
26
px
)
auto
;
background
-
size
:
24
px
auto
;
}
}
.
btn
-
pause
{
.
btn
-
pause
{
background
-
image
:
url
(
'~@/images/video/pause.png'
);
background
-
image
:
url
(
'~@/images/video/pause.png'
);
background
-
position
:
50
%
50
%
;
}
background
-
size
:
px2rem
(
24
px
)
auto
;
.
progress
-
box
{
position
:
relative
;
display
:
flex
;
align
-
items
:
center
;
flex
:
1
;
width
:
50
px
;
height
:
44
px
;
margin
-
left
:
5
px
;
}
.
progress
-
inner
{
position
:
relative
;
width
:
50
px
;
flex
:
1
;
height
:
2
px
;
background
:
rgba
(
255
,
255
,
255
,
0.4
);
overflow
:
hidden
;
}
.
progress
-
bar
{
position
:
absolute
;
left
:
-
100
%
;
top
:
0
;
width
:
100
%
;
height
:
100
%
;
background
:
#
449284
;
transform
:
translateX
(
0
);
pointer
-
events
:
none
;
}
.
progress
-
ball
{
position
:
absolute
;
left
:
0
;
top
:
50
%
;
width
:
7
px
;
height
:
14
px
;
transform
:
translate3d
(
-
3
px
,
-
7
px
,
0
);
background
-
color
:
#
fff
;
border
-
radius
:
2
px
;
}
}
.
time
-
box
{
.
time
-
box
{
color
:
#
fff
;
color
:
#
fff
;
font
-
size
:
1
4
px
;
font
-
size
:
1
2
px
;
line
-
height
:
14
px
;
line
-
height
:
14
px
;
letter
-
spacing
:
1
px
;
width
:
100
px
;
margin
-
left
:
12
px
;
text
-
align
:
right
;
}
.
bar
-
empty
{
flex
:
1
;
width
:
1
px
;
}
}
.
btn
-
screen
{
.
btn
-
screen
{
width
:
px2rem
(
44
px
)
;
width
:
44
px
;
height
:
px2rem
(
44
px
)
;
height
:
44
px
;
background
-
image
:
url
(
'~@/images/video/screen_full.png'
);
background
-
image
:
url
(
'~@/images/video/screen_full.png'
);
background
-
repeat
:
no
-
repeat
;
background
-
repeat
:
no
-
repeat
;
background
-
position
:
50
%
50
%
;
background
-
position
:
50
%
50
%
;
background
-
size
:
px2rem
(
20
px
)
auto
;
background
-
size
:
20
px
auto
;
}
}
.
btn
-
screen
-
mini
{
.
btn
-
screen
-
mini
{
background
-
image
:
url
(
'~@/images/video/screen_mini.png'
);
background
-
image
:
url
(
'~@/images/video/screen_mini.png'
);
}
}
.
progress
-
box
{
.
rate
-
box
{
position
:
relative
;
color
:
#
fff
;
width
:
40
px
;
height
:
44
px
;
line
-
height
:
44
px
;
font
-
size
:
12
px
;
text
-
align
:
center
;
}
.
rate
-
list
{
position
:
absolute
;
position
:
absolute
;
left
:
0
;
left
:
0
;
top
:
0
;
bottom
:
44
px
;
width
:
100
%
;
width
:
100
%
;
padding
:
3
px
0
;
background
:
rgba
(
0
,
0
,
0
,
.
7
);
border
-
radius
:
2
px
;
}
}
.
progress
-
inner
{
.
rate
-
item
{
position
:
relative
;
height
:
30
px
;
height
:
4
px
;
line
-
height
:
30
px
;
background
:
rgba
(
255
,
255
,
255
,
0.4
);
}
}
.
progress
-
bar
{
.
rate
-
active
{
position
:
absolute
;
color
:
#
00
a1d6
;
left
:
-
100
%
;
top
:
0
;
width
:
100
%
;
height
:
100
%
;
background
:
#
449284
;
transform
:
translateX
(
0
);
pointer
-
events
:
none
;
}
}
.
proved
-
box
{
.
proved
-
box
{
position
:
absolute
;
position
:
absolute
;
color
:
#
fff
;
color
:
#
fff
;
font
-
size
:
1
4
px
;
font
-
size
:
1
2
px
;
left
:
20
px
;
left
:
20
px
;
bottom
:
70
px
;
bottom
:
70
px
;
height
:
30
px
;
height
:
30
px
;
...
@@ -440,7 +541,7 @@ export default {
...
@@ -440,7 +541,7 @@ export default {
}
}
.
cover
-
play
{
.
cover
-
play
{
background
:
url
(
'~@/images/video/cover_play.png'
)
no
-
repeat
center
center
;
background
:
url
(
'~@/images/video/cover_play.png'
)
no
-
repeat
center
center
;
background
-
size
:
px2rem
(
50
px
)
auto
;
background
-
size
:
50
px
auto
;
}
}
.
cover
-
error
,
.
cover
-
resume
{
.
cover
-
error
,
.
cover
-
resume
{
p
{
p
{
...
@@ -449,7 +550,7 @@ export default {
...
@@ -449,7 +550,7 @@ export default {
top
:
50
%
;
top
:
50
%
;
width
:
100
%
;
width
:
100
%
;
color
:
#
fff
;
color
:
#
fff
;
font
-
size
:
1
8
px
;
font
-
size
:
1
5
px
;
text
-
align
:
center
;
text
-
align
:
center
;
transform
:
translate3d
(
0
,
-
50
%
,
0
);
transform
:
translate3d
(
0
,
-
50
%
,
0
);
}
}
...
...
src/images/video/screen_full.png
查看替换文件 @
3ab45d93
浏览文件 @
cb0609c7
679 字节
|
W:
|
H:
1.1 KB
|
W:
|
H:
2-up
Swipe
Onion skin
src/images/video/screen_mini.png
查看替换文件 @
3ab45d93
浏览文件 @
cb0609c7
692 字节
|
W:
|
H:
1.2 KB
|
W:
|
H:
2-up
Swipe
Onion skin
src/style/common.scss
浏览文件 @
cb0609c7
...
@@ -28,6 +28,26 @@ body, div, span, header, footer, nav, section, aside, article, ul, dl, dt, dd, l
...
@@ -28,6 +28,26 @@ body, div, span, header, footer, nav, section, aside, article, ul, dl, dt, dd, l
}
}
}
}
img
,
a
,
div
{
-webkit-tap-highlight-color
:
rgba
(
0
,
0
,
0
,
0
);
-webkit-touch-callout
:
none
;
-webkit-user-select
:
none
;
}
::selection
{
background
:
none
;
}
::-moz-selection
{
background
:
none
;
}
::-webkit-selection
{
background
:
none
;
}
/*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
/*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
::-webkit-scrollbar
::-webkit-scrollbar
{
{
...
...
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录