Class MediaUtils
Provides static utility methods for handling media-related operations.
public static class MediaUtils
- Inheritance
-
MediaUtils
- Inherited Members
Fields
Mapping
public static readonly Dictionary<string, string> Mapping
Field Value
Methods
GetMimeType(string)
Determines the MIME type associated with the file extension of the specified path.
Performs a case-insensitive lookup against a known extension mapping and falls back to application/octet-stream when the extension is not recognized.
public static string GetMimeType(string filePath)
Parameters
filePathstringThe file path whose extension is used to resolve the MIME type.
Returns
- string
The corresponding MIME type string if the extension is found in the mapping; otherwise, the default
application/octet-streamvalue.
GetVideoDuration(string)
Retrieves the duration of the video at the specified path, expressed in milliseconds. Returns null if the duration cannot be read, with the underlying error logged to the console.
public static long? GetVideoDuration(string videoPath)
Parameters
videoPathstringThe file path of the video whose duration should be retrieved.
Returns
- long?
The video duration in milliseconds, or null if an error occurs while reading the file.
IsVideoFile(string)
Determines whether the specified file path corresponds to a supported video file by comparing its extension against a predefined list of video formats (e.g., .mp4, .avi, .mkv, .mov). The comparison is case-insensitive.
public static bool IsVideoFile(string filePath)
Parameters
filePathstringThe path of the file to evaluate.
Returns
- bool
trueif the file extension matches one of the supported video extensions; otherwise,false.