mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-25 08:01:20 -08:00
add more file
This commit is contained in:
1 parent
506b34522b
commit
73283a838a
26 files changed
+435
-51
No files matched your search
+7
-7
@@ -11,11 +11,12 @@ export default class Player {
|
||||
init() {
|
||||
const { option } = this.art;
|
||||
const { $video } = this.art.refs;
|
||||
$video.controls = false;
|
||||
$video.controls = true;
|
||||
$video.poster = option.poster;
|
||||
$video.volume = clamp(option.volume, 0, 1);
|
||||
$video.autoplay = option.autoplay;
|
||||
$video.preload = option.preload;
|
||||
$video.src = option.url;
|
||||
}
|
||||
|
||||
eventBind() {
|
||||
@@ -68,14 +69,14 @@ export default class Player {
|
||||
}
|
||||
|
||||
play() {
|
||||
const { refs: { $video } } = this.art;
|
||||
const { $video } = this.art.refs;
|
||||
const promise = $video.play();
|
||||
this.art.emit('play', $video);
|
||||
return promise;
|
||||
}
|
||||
|
||||
pause() {
|
||||
const { refs: { $video } } = this.art;
|
||||
const { $video } = this.art.refs;
|
||||
$video.pause();
|
||||
this.art.emit('pause', $video);
|
||||
}
|
||||
@@ -89,7 +90,7 @@ export default class Player {
|
||||
}
|
||||
|
||||
seek(time) {
|
||||
const { refs: { $video } } = this.art;
|
||||
const { $video } = this.art.refs;
|
||||
let newTime = Math.max(time, 0);
|
||||
if ($video.duration) {
|
||||
newTime = Math.min(newTime, $video.duration);
|
||||
@@ -104,11 +105,10 @@ export default class Player {
|
||||
}
|
||||
|
||||
volume(percentage) {
|
||||
const { refs: { $video } } = this.art;
|
||||
const { $video } = this.art.refs;
|
||||
if (percentage) {
|
||||
$video.volume = clamp(percentage, 0, 1);
|
||||
}
|
||||
|
||||
this.art.emit('volume', $video.volume);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ export default class Player {
|
||||
}
|
||||
|
||||
speed(rate) {
|
||||
const { refs: { $video } } = this.art;
|
||||
const { $video } = this.art.refs;
|
||||
$video.playbackRate = rate;
|
||||
this.art.emit('speed', rate);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user