mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-19 19:51:20 -08:00
压缩字符
This commit is contained in:
1 parent
7ff61b4660
commit
0cf455ced3
27 files changed
+171
-239
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { query, append, setStyle, setStyles, errorHandle, getExt, vttToBlob, srtToVtt, assToVtt } from '../utils';
|
||||
import { query, append, setStyle, setStyles, errorHandle, getExt } from '../utils';
|
||||
|
||||
export default function localSubtitle(art) {
|
||||
const {
|
||||
@@ -12,31 +12,9 @@ export default function localSubtitle(art) {
|
||||
if (file) {
|
||||
const type = getExt(file.name);
|
||||
if (['ass', 'vtt', 'srt'].includes(type)) {
|
||||
const reader = new FileReader();
|
||||
proxy(reader, 'load', event => {
|
||||
const text = event.target.result;
|
||||
switch (type) {
|
||||
case 'srt': {
|
||||
const url = vttToBlob(srtToVtt(text));
|
||||
subtitle.switch(url, file.name);
|
||||
break;
|
||||
}
|
||||
case 'ass': {
|
||||
const url = vttToBlob(assToVtt(text));
|
||||
subtitle.switch(url, file.name);
|
||||
break;
|
||||
}
|
||||
case 'vtt': {
|
||||
const url = vttToBlob(text);
|
||||
subtitle.switch(url, file.name);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
art.emit('localSubtitle', file);
|
||||
});
|
||||
reader.readAsText(file);
|
||||
const url = URL.createObjectURL(file);
|
||||
subtitle.switch(url, file.name, type);
|
||||
art.emit('localSubtitle', file);
|
||||
} else {
|
||||
errorHandle(false, 'Only supports subtitle files in .ass, .vtt and .srt format');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user