This answer về P/Gọi cho Shell32 nhắc tôi về số Windows API Code Pack để truy cập các API Windows Vista/7/2008/2008R2 phổ biến. Nó là rất dễ dàng, bằng cách sử dụng bản demo PropertyEdit trong các mẫu được bao gồm, để tìm ra Shell32 API để nhận các thuộc tính tệp phương tiện khác nhau, như thời lượng.
Tôi giả sử các điều kiện tiên quyết này cũng áp dụng cho có Demultiplexers thích hợp cài đặt, nhưng nó là khá đơn giản, vì nó chỉ cần thêm tài liệu tham khảo để Microsoft.WindowsAPICodePack.dll
và Microsoft.WindowsAPICodePack.Shell.dll
và đoạn mã sau:
using Microsoft.WindowsAPICodePack.Shell;
using Microsoft.WindowsAPICodePack.Shell.PropertySystem;
using (ShellPropertyCollection properties = new ShellPropertyCollection(filePath))
{
foreach (IShellProperty prop in properties)
{
string value = (prop.ValueAsObject == null) ? "" : prop.FormatForDisplay(PropertyDescriptionFormatOptions.None);
Console.WriteLine("{0} = {1}", prop.CanonicalName, value);
}
}
using (ShellObject shell = ShellObject.FromParsingName(filePath))
{
// alternatively: shell.Properties.GetProperty("System.Media.Duration");
IShellProperty prop = shell.Properties.System.Media.Duration;
// Duration will be formatted as 00:44:08
string duration = prop.FormatForDisplay(PropertyDescriptionFormatOptions.None);
}
Một số tài sản chung cho một MPEG-4/AAC audio file media:
System.Audio.Format = {00001610-0000-0010-8000-00AA00389B71}
System.Media.Duration = 00:44:08
System.Audio.EncodingBitrate = ?56kbps
System.Audio.SampleRate = ?32 kHz
System.Audio.SampleSize = ?16 bit
System.Audio.ChannelCount = 2 (stereo)
System.Audio.StreamNumber = 1
System.DRM.IsProtected = No
System.KindText = Music
System.Kind = Music
API DirectShot này ở đâu? Bạn cũng có thể cung cấp cho tôi url của phần thứ ba này không? Hay bạn có ý nghĩa như kite lite Mã hóa gói – MonsterMMORPG
Alright đã thử một tệp và nó hiển thị thời lượng NAN: D – MonsterMMORPG
Cảm ơn dòng này cho thời lượng chính xác như giây: mediaDet.get_StreamLength (ngoài phương tiện truyền thông), – MonsterMMORPG