简体   繁体   中英

Get Music Duration stored in Isolated Storage

I am using MusicProerties to get music duration, but it throws exception.

StorageFolder localRoot = Windows.Storage.ApplicationData.Current.LocalFolder;
StorageFolder mp3 = await localRoot.GetFolderAsync(Path.GetDirectoryName(fileFullPath));
StorageFile file = await mp3.GetFileAsync(Path.GetFileName(fileFullPath));
Windows.Storage.FileProperties.MusicProperties music = await file.Properties.GetMusicPropertiesAsync(); //Exception is thrown here

double duration = music.Duration.TotalSeconds;

The exception is:

{System.NotSupportedException: Specified method is not supported.
   at Windows.Storage.StorageFile.get_Properties()

I am afraid if this is not supported in windows phone 8.

Yes you are right - this API as MSDN says is not implemented yet:

Windows Phone 8

This API is not implemented and will throw an exception if called. See Windows Phone Runtime API.

AFAIK for now there is no simple method to get duration from audio file properties,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM