I need the media length from Audio and Video URL which is stored in Amazon S3 Cloud storage. I have tried wmplib and directshow lib but both are used to get the duration or length when the file is stored temporarily in file system. I need to get the media length by directly passing the cloud URL.
I have also used Windows APICodePack.Shell library. All these libraries can be used to get duration of a locally stored file.
How this can be achieved?
Using Windows APICodePack.Shell
using Microsoft.WindowsAPICodePack.Shell;
ShellFile so = ShellFile.FromFilePath(file);
double nanoseconds;
double.TryParse(so.Properties.System.Media.Duration.Value.ToString(),
out nanoseconds);
Console.WriteLine("NanaoSeconds: {0}", nanoseconds);
Using WMPLib
WindowsMediaPlayerClass wmp = new WindowsMediaPlayerClass();
IWMPMedia mediaInfo = wmp.newMedia(filePath);
return mediaInfo.durationString