Adding subtitle metadata or options to add metadata to imported subtitles
Opened this issue · 1 comments
Hi! Been using this for over a year now, it's great! Just one thing.
With imported vtt/srt files I only get track1, track2 names instead of the actual language name on my tracklist.
Would you guys be so kind to add reading off metadata in file and set it as name instead of just using indexing as track names?
This way users will just add metadata to srt/vtt files like title, name, srclang, kind etc on em and you can just set it up on the backend.
Or maybe add an option to addSubtitleFromNetwork like this perhaps?
ctrl.addSubtitleFromNetwork('http://mysite.site/moviesubtitle.vtt', {name: English(SDH), srclang: en, kind: captions});
And return said data to getSpuTracks()? Instead of just returning the index and the name of the track,
just like the web does for its texttracklists?
This would make me and a lot of people very happy.
Hi! For anyone wondering any "hacky" way to do it. All I did was pair the getSpuTracks() list indexes to the index of the captions list, since vlc indexes can be random at times; starting from 1 or two sometimes 3 or way out to 5. I'm thinking because the video populates index 0, and audios populates the next, so subtitles would probably continue from where the last audio index is. So, if you have a list of Caption objects with fields of name, srclang, and kind; the corresponding sputrack index of that list would probably start with either usually 2 or 3 instead of 0. So you make a new object maybe call it vlcConf that holds both the caption name and the sputrack index.
Now when you want to display the name of the subtitle(which is just the language itself, with the option of adding SDH, etc) you can iterate over the Caption list and display them onscreen whenever requested. And if one is chosen, get the chosen caption's index and then place it in like this ctrl.setSpuTrack(vlcConf[caption_index].index); Where caption_index is the index of the Caption object list, and .index is the index of the sputrack itself.
This way now you have control of the naming, and how it populates your subtitle menu.
This only works for manually added subtitles though. VLC can extract the names of built-in subtitles no prob(only if the subtitles have their metadata right, if not you get track 1s and multiple subtitles with the same language names).