Open vnali opened 1 year ago
Nice job, I will check this commit next week :)
Refactored code, check the newest commit from the "master" branch.
Added a new class for Webvtt.
Now you can add the speaker like this (as you suggested):
(new Webvtt)->add(0, 1, ['John' => 'hello', 'hello to you too'])->...
Also changed the name of styles (vtt_cue_settings -> settings):
(new Webvtt)->add(0, 1, 'hello', ['settings' => 'position:50% line:15% align:middle'])->...
Webtt class saves everything to the vtt key:
$internal_format[0]['vtt']
For the srt file detection of the speaker is not accurate. Checked a few files and there is text like:
These colors: blue, green and red
Which would set "These colors" as a speaker.
So for now left srt as is.
What do you think?
You are definitly right about false detection of SRT files, so we must skip SRT speaker detection for now, but:
add()
for generating other types with known speaker format like SRT and Asking people to do (new Webvtt)->add(0, 1, ['John' => 'hello', 'hello to you too'])->content('srt')
is weird. i have a feeling we should have a general add()
.add()
too, maybe we could change it to inline_cue_settings or ['vtt']['cue_settings'], ...Please let me know if i misunderstood something Thanks!
This PR is related to https://github.com/mantas-done/subtitles/issues/61
This PR:
$internal_format['speakers']
and if there is any speaker, attaches<v {speaker_name}>
to the beginning and</v>
to the end of the line.$internal_format['speakers']
and if there is any speaker, attaches{speaker_name}:
to the beginning of the line.add()
a subtitle, you can pass the speaker as keys of third param.->add(0, 1, ['{speaker_name}' => 'Line 1', 'Line 2'])
->add(1, 2, ['Line 1', '{speaker_name}' =>'Line2'])
->add(2, 3, ['{speaker_name}' => 'Line 1', '{speaker_name}' =>'Line2'])
->add(3, 4, ['Line 1', 'speaker2: Line2']) // If the speaker is not available -Line1- or it is already included in the line -Line2-, you should not pass speaker separately.