[Utilities] - Cache video file extension.

This commit is contained in:
Ivandro Ismael 2016-11-02 23:01:32 +00:00
parent 86b5f80aae
commit a95b8a9699
6 changed files with 10 additions and 11 deletions

View File

@ -63,7 +63,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
fileNameNoExt = _fileName.Substring(0, _fileName.Length - Path.GetExtension(_fileName).Length);
}
foreach (var ext in Utilities.GetMovieFileExtensions())
foreach (var ext in Utilities.VideoFileExtensions)
{
if (!string.IsNullOrEmpty(fileNameNoExt) && File.Exists(Path.Combine(fileNameNoExt, ext)))
{

View File

@ -116,17 +116,16 @@ namespace Nikse.SubtitleEdit.Core
return info;
}
public static List<string> GetMovieFileExtensions()
{
return new List<string> { ".avi", ".mkv", ".wmv", ".mpg", ".mpeg", ".divx", ".mp4", ".asf", ".flv", ".mov", ".m4v", ".vob", ".ogv", ".webm", ".ts", ".m2ts", ".avs", ".mxf" };
}
// TODO: Change to IReadonlyList in .net >= 4.5
public static ICollection<string> VideoFileExtensions { get; } = new List<string>
{ ".avi", ".mkv", ".wmv", ".mpg", ".mpeg", ".divx", ".mp4", ".asf", ".flv",".mov", ".m4v", ".vob", ".ogv", ".webm", ".ts", ".m2ts", ".avs", ".mxf" };
public static string GetVideoFileFilter(bool includeAudioFiles)
{
var sb = new StringBuilder();
sb.Append(Configuration.Settings.Language.General.VideoFiles + "|");
int i = 0;
foreach (string extension in GetMovieFileExtensions())
foreach (string extension in VideoFileExtensions)
{
if (i > 0)
sb.Append(';');

View File

@ -139,7 +139,7 @@ namespace Nikse.SubtitleEdit.Forms
try
{
string ext = Path.GetExtension(fileName).ToLower();
if (Utilities.GetMovieFileExtensions().Contains(ext))
if (Utilities.VideoFileExtensions.Contains(ext))
{
var fi = new FileInfo(fileName);
if (ext == ".mkv" && FileUtil.IsVobSub(fileName))

View File

@ -13424,7 +13424,7 @@ namespace Nikse.SubtitleEdit.Forms
{
string movieFileName = null;
foreach (var extension in Utilities.GetMovieFileExtensions())
foreach (var extension in Utilities.VideoFileExtensions)
{
var fileName = fileNameNoExtension + extension;
if (File.Exists(fileName))
@ -15801,7 +15801,7 @@ namespace Nikse.SubtitleEdit.Forms
string ext = Path.GetExtension(fileName).ToLowerInvariant();
if (ext != ".wav" || !WavePeakGenerator.IsFileValidForVisualizer(fileName))
{
if (audioVisualizer.WavePeaks == null && (Utilities.GetMovieFileExtensions().Contains(ext) || ext == ".wav" || ext == ".mp3" || ext == ".mka" || ext == ".m4a" || ext == ".wma"))
if (audioVisualizer.WavePeaks == null && (Utilities.VideoFileExtensions.Contains(ext) || ext == ".wav" || ext == ".mp3" || ext == ".mka" || ext == ".m4a" || ext == ".wma"))
{
_videoFileName = fileName;
AudioWaveform_Click(null, null);

View File

@ -70,7 +70,7 @@ namespace Nikse.SubtitleEdit.Forms
{
string movieFileName = null;
foreach (string extension in Utilities.GetMovieFileExtensions())
foreach (string extension in Utilities.VideoFileExtensions)
{
movieFileName = fileNameNoExtension + extension;
if (File.Exists(movieFileName))

View File

@ -369,7 +369,7 @@ namespace Nikse.SubtitleEdit.Forms
{
string movieFileName = null;
foreach (string extension in Utilities.GetMovieFileExtensions())
foreach (string extension in Utilities.VideoFileExtensions)
{
movieFileName = fileNameNoExtension + extension;
if (File.Exists(movieFileName))