mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 19:22:53 +01:00
[Utilities] - Cache video file extension.
This commit is contained in:
parent
86b5f80aae
commit
a95b8a9699
@ -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)))
|
||||
{
|
||||
|
@ -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(';');
|
||||
|
@ -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))
|
||||
|
@ -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);
|
||||
|
@ -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))
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user