修复本地视频初始化问题

This commit is contained in:
Harvey Zack committed 2018-12-02 10:49:15 +08:00
1 parent 5c067c2c47
commit 6deccca9be
2 files changed
+26 -4

No files matched your search

@@ -17,15 +17,18 @@ export default function artplayerPluginLocalPreview(art) {
append,
setStyle,
setStyles,
sleep,
} = art.constructor.utils;
const formats = ['mp4', 'ogg', 'webm'];
const {
events: {
proxy,
},
option,
notice,
i18n,
template,
player,
} = art;
i18nMix(i18n);
@@ -49,7 +52,15 @@ export default function artplayerPluginLocalPreview(art) {
}
const ext = getExt(file.name);
if (ext && formats.includes(ext)) {
template.$video.src = URL.createObjectURL(file);
const url = URL.createObjectURL(file);
player.playbackRateRemove();
player.aspectRatioRemove();
template.$video.src = url;
sleep(100).then(() => {
player.seek(0);
});
option.url = url;
art.emit('switch', url);
notice.show(i18n.get('Load local video successfully'));
} else {
const tip = `${i18n.get('Only file types are supported')}: ${formats.toString()}`;