mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-25 16:11:20 -08:00
添加sourcemap
This commit is contained in:
1 parent
03605262bd
commit
01e16b042c
18 files changed
+119
-49
No files matched your search
@@ -21,9 +21,41 @@ export default function localPreview(art) {
|
||||
template,
|
||||
player,
|
||||
} = art;
|
||||
const fileTypes = ['video/mp4', 'audio/ogg', 'video/webm'];
|
||||
i18nMix(i18n);
|
||||
|
||||
function loadVideo(file) {
|
||||
const fileTypes = ['video/mp4', 'audio/ogg', 'video/webm'];
|
||||
if (file) {
|
||||
if (fileTypes.includes(file.type)) {
|
||||
const url = URL.createObjectURL(file);
|
||||
player.playbackRateRemove();
|
||||
player.aspectRatioRemove();
|
||||
template.$video.src = url;
|
||||
sleep(1000).then(() => {
|
||||
player.currentTime = 0;
|
||||
});
|
||||
option.url = url;
|
||||
art.emit('switch', url);
|
||||
notice.show(i18n.get('Load local video successfully'));
|
||||
} else {
|
||||
const tip = `${file.type}, ${i18n.get('Only file types are supported')}: ${fileTypes.toString()}`;
|
||||
notice.show(tip, true, 3000);
|
||||
console.warn(tip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
proxy(template.$player, 'dragover', e => {
|
||||
e.preventDefault();
|
||||
notice.show(i18n.get('Load local video successfully'));
|
||||
});
|
||||
|
||||
proxy(template.$player, 'drop', e => {
|
||||
e.preventDefault();
|
||||
const file = e.dataTransfer.files[0];
|
||||
loadVideo(file);
|
||||
});
|
||||
|
||||
return {
|
||||
name: 'localPreview',
|
||||
attach(target) {
|
||||
@@ -39,24 +71,7 @@ export default function localPreview(art) {
|
||||
});
|
||||
proxy($input, 'change', () => {
|
||||
const file = $input.files[0];
|
||||
if (file) {
|
||||
if (fileTypes.includes(file.type)) {
|
||||
const url = URL.createObjectURL(file);
|
||||
player.playbackRateRemove();
|
||||
player.aspectRatioRemove();
|
||||
template.$video.src = url;
|
||||
sleep(100).then(() => {
|
||||
player.currentTime = 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')}: ${fileTypes.toString()}, but got ${file.type}`;
|
||||
notice.show(tip, true, 3000);
|
||||
console.warn(tip);
|
||||
}
|
||||
}
|
||||
loadVideo(file);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user