I making windows forms application with MediaInfo Wrapper and I can't find any good solution to get all subtitles and put them in to the array or string.
Because if I hard code subtitle1, subtitle2, subtitle3, subtitle4 etc... and there is no subtitles at all or that much I hard coded, I got error:
Input string was not in a correct format
So how I can get subtitles and list them in string or array nicely like this: Eng, Fra, Spa without hard code and above error. (I got this error everytime if there is no subs).
My code:
// Hardcoding (possible) subtitles...
string subOne = MI.Get(StreamKind.Text, 0, "Language/String3");
string subTwo = MI.Get(StreamKind.Text, 1, "Language/String3");
string subThree = MI.Get(StreamKind.Text, 2, "Language/String3");
string subtitlesCount = MI.Get(StreamKind.General, 0, "TextCount"); // Count how many subtitles included
string subtitles = "";
int subtitlesInt = Int32.Parse(subtitlesCount);
// Trying to find better solution over here...
if (subtitlesInt >= 1 && subtitlesInt < 2)
{
subtitles = subOne;
} else if (subtitlesInt >= 1 && subtitlesInt <= 2)
{
subtitles = subOne + "," + subTwo;
} else {
subtitles = "";
}
//var subsArray = subtitles.Split(',');
//subtitles = String.Join(",", subsArray);
// Display mediainfo data to textbox
string data = "";
data += "Subtitles: " + subtitles + "\r\n";