mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-11 13:56:15 -08:00
34 lines
754 B
JavaScript
34 lines
754 B
JavaScript
import { clamp, sleep } from '../utils';
|
|
|
|
export default function attrInit(art, player) {
|
|
const {
|
|
option,
|
|
refs: { $video },
|
|
} = art;
|
|
Object.keys(option.moreVideoAttr).forEach(key => {
|
|
$video[key] = option.moreVideoAttr[key];
|
|
});
|
|
|
|
if (option.muted) {
|
|
$video.muted = option.muted;
|
|
}
|
|
|
|
if (option.volume) {
|
|
$video.volume = clamp(option.volume, 0, 1);
|
|
}
|
|
|
|
if (option.poster) {
|
|
$video.poster = option.poster;
|
|
}
|
|
|
|
if (option.autoplay) {
|
|
$video.autoplay = option.autoplay;
|
|
}
|
|
|
|
sleep().then(() => {
|
|
art.emit('beforeMountUrl', option.url);
|
|
$video.src = player.mountUrl(option.url);
|
|
art.emit('afterMountUrl', option.url);
|
|
});
|
|
}
|