Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have an issue while reading duration of m4a file using C#
its showing me 0.0 duration while its size is more than 1600 Kb
can anyone guide me about what the actual reason of this type of file.
in the same code other m4a files calculate the correct duration.
your quick response will be appreciated
Thanks in advance.
[Wajid Hussain]

What I have tried:

here is code that i m trying

ShellFile so = ShellFile.FromFilePath(fromPath);
               double nanoseconds;
               double.TryParse(so.Properties.System.Media.Duration.Value.ToString(), out nanoseconds);
               Console.WriteLine("NanaoSeconds: {0}", nanoseconds);
               if (nanoseconds > 0)
               {
                   // double milliseconds = nanoseconds * 0.000001;
                   double seconds = Convert100NanosecondsToMilliseconds(nanoseconds) / 1000;
                   string duration=  Convert.ToInt64(seconds) / 60 + ":" + Convert.ToInt64(seconds) % 60;
                   Console.WriteLine(duration.ToString());
               }
Posted
Comments
Richard MacCutchan 19-Jan-19 4:40am    
You need to inspect the content of the file.
[no name] 21-Jan-19 12:32pm    
Try looking at the file properties in Windows Explorer. It could be that the file header has been corrupted, therefore, the Windows file properties would show the same.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900