Click here to Skip to main content
15,894,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How i get duration at mvc-4 ??

i read all of posts , but i cant add some of dlls and some of dlls do not work .

now i am using:

from
C#
Microsoft.WindowsAPICodePack.Shell
and
C#
Microsoft.WindowsAPICodePack.Shell.PropertySystem
these namespace get me just duration of mp-3 . but do not get duration *.flv. This code is for mp3 :
C#
using Microsoft.WindowsAPICodePack.Shell;
using Microsoft.WindowsAPICodePack.Shell.PropertySystem;

public static double Convert100NanosecondsToMilliseconds(double nanoseconds)
{
    return nanoseconds * 0.0001;
}

below code is in my action :
C#
var fle = "Path of mp3";
ShellFile so = ShellFile.FromFilePath(fle);
double nanoseconds;
double.TryParse(so.Properties.System.Media.Duration.Value.ToString(), out nanoseconds);
if (nanoseconds > 0 )
{
    double seconds = Convert100NanosecondsToMilliseconds(nanoseconds) / 1000;
    double time = Math.Round(seconds / 60, 1);
    string res = time.ToString();
}

my visual studio is 2013 .
my windows is 8 .
Posted
Updated 7-May-14 23:55pm
v2

1 solution

see here[^]
 
Share this answer
 
Comments
jimjimy 8-May-14 5:51am    
Hi @Vi(ky . I use from this sample but this work just for audio .

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