Click here to Skip to main content
14,641,854 members
Rate this:
Please Sign up or sign in to vote.
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;
Richard MacCutchan 19-Jan-19 4:40am
You need to inspect the content of the file.
Donathan.Hutchings 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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100