Files
ArtPlayer/packages/artplayer/src/player/attrInit.js
T
2019-11-28 10:10:29 +08:00

38 lines
757 B
JavaScript

import { clamp } from '../utils';
export default function attrInit(art, player) {
const {
option,
storage,
template: { $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);
}
const volume = storage.get('volume');
if (volume) {
$video.volume = clamp(volume, 0, 1);
}
if (option.poster) {
$video.poster = option.poster;
}
if (option.autoplay) {
$video.autoplay = option.autoplay;
}
$video.controls = false;
player.url = option.url;
}