Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function* subtitlesReloadSaga (_action) {
const scope = yield select(state => state.get('scope'));
const {selectedKey: key, availableOptions} = yield select(state => state.get('subtitles'));
if (key) {
/* Generate an initial item covering the entire recording (needed because
the editor works by splitting existing items at a specific position). */
let text = (availableOptions[key].text || '').trim();
if (!text) {
const data = yield select(state => state.getIn(['player', 'data']));
text = srtStringify([{start: 0, end: data.events[data.events.length - 1][0], text: ''}]);
}
yield put({type: scope.subtitlesLoadFromText, payload: {key, text}});
}
}
import * as Subtitle from 'subtitle';
Subtitle.parse("");
const subtitles = [
{
start: '00:00:20,000',
end: '00:00:24,400',
text: 'Bla Bla Bla Bla'
},
{
start: 24600,
end: 27800,
text: 'Bla Bla Bla Bla',
settings: 'align:middle line:90%'
}
];
const srt = Subtitle.stringify(subtitles);
start: '00:00:20,000',
end: '00:00:24,400',
text: 'Bla Bla Bla Bla'
},
{
start: 24600,
end: 27800,
text: 'Bla Bla Bla Bla',
settings: 'align:middle line:90%'
}
];
const srt = Subtitle.stringify(subtitles);
const vtt = Subtitle.stringifyVtt(subtitles);
const newSubtitles: Subtitle.subTitleType[] = Subtitle.resync(subtitles, 1000);
Subtitle.toMS('00:00:24,400');
Subtitle.toSrtTime(24400);
Subtitle.toVttTime(24400);
const subtitles = [
{
start: '00:00:20,000',
end: '00:00:24,400',
text: 'Bla Bla Bla Bla'
},
{
start: 24600,
end: 27800,
text: 'Bla Bla Bla Bla',
settings: 'align:middle line:90%'
}
];
const srt = Subtitle.stringify(subtitles);
const vtt = Subtitle.stringifyVtt(subtitles);
const newSubtitles: Subtitle.subTitleType[] = Subtitle.resync(subtitles, 1000);
Subtitle.toMS('00:00:24,400');
Subtitle.toSrtTime(24400);
Subtitle.toVttTime(24400);
const subtitles = [
{
start: '00:00:20,000',
end: '00:00:24,400',
text: 'Bla Bla Bla Bla'
},
{
start: 24600,
end: 27800,
text: 'Bla Bla Bla Bla',
settings: 'align:middle line:90%'
}
];
const srt = Subtitle.stringify(subtitles);
const vtt = Subtitle.stringifyVtt(subtitles);
const newSubtitles: Subtitle.subTitleType[] = Subtitle.resync(subtitles, 1000);
Subtitle.toMS('00:00:24,400');
Subtitle.toSrtTime(24400);
Subtitle.toVttTime(24400);
text: 'Bla Bla Bla Bla'
},
{
start: 24600,
end: 27800,
text: 'Bla Bla Bla Bla',
settings: 'align:middle line:90%'
}
];
const srt = Subtitle.stringify(subtitles);
const vtt = Subtitle.stringifyVtt(subtitles);
const newSubtitles: Subtitle.subTitleType[] = Subtitle.resync(subtitles, 1000);
Subtitle.toMS('00:00:24,400');
Subtitle.toSrtTime(24400);
Subtitle.toVttTime(24400);
{
start: 24600,
end: 27800,
text: 'Bla Bla Bla Bla',
settings: 'align:middle line:90%'
}
];
const srt = Subtitle.stringify(subtitles);
const vtt = Subtitle.stringifyVtt(subtitles);
const newSubtitles: Subtitle.subTitleType[] = Subtitle.resync(subtitles, 1000);
Subtitle.toMS('00:00:24,400');
Subtitle.toSrtTime(24400);
Subtitle.toVttTime(24400);
end: 27800,
text: 'Bla Bla Bla Bla',
settings: 'align:middle line:90%'
}
];
const srt = Subtitle.stringify(subtitles);
const vtt = Subtitle.stringifyVtt(subtitles);
const newSubtitles: Subtitle.subTitleType[] = Subtitle.resync(subtitles, 1000);
Subtitle.toMS('00:00:24,400');
Subtitle.toSrtTime(24400);
Subtitle.toVttTime(24400);
private async parseSubtitleFile(url: string): Promise {
const log = this.instance.log('SubtitlesExtension.parseSubtitleFile');
if (!this.timingsCache[url]) {
try {
const content = await fetch(url).then(response => response.text());
this.timingsCache[url] = SubtitleParser.parse(content);
log(`Parsed ${url}`, { trackTimings: this.timingsCache[url] });
} catch (error) {
this.timingsCache[url] = [];
log(`Failed to parse ${url}`);
}
}
return this.timingsCache[url];
}
}
function get_lyrics(srt) {
let xhr = new XMLHttpRequest();
let data = "";
xhr.open('GET', "https://files.shishnet.org/karakara-demo/"+srt, false);
xhr.onload = function(e) {
data = e.target.responseText;
};
xhr.send();
return Subtitle.parse(data);
}