JoJo
JoJo

Reputation: 4923

How to get an .MP4 Play Length with .NET (C#) or JavaScript?

I need the play length value from .MP4 files that are uploaded with RadAsyncUpload.

This Length value is seen when you right-click an .MP4 file and click the details tab.

How can this be accomplished inside a Web app? I imagine If it is possible with JavaScript I could pass the value to .Net or just use Telerik and .NET combined.

Thanks.

Upvotes: 0

Views: 302

Answers (1)

Arindam Nayak
Arindam Nayak

Reputation: 7462

You can do that easily in javascript. Follow the attached example. After getting that value from javascript post that time to serverside, and get that in serverside if you need there.

function gettime() {
  var vid = document.getElementById("vid");
  alert(vid.duration);
}
<video width="320" height="240" controls id="vid">
  <source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
    <source src="http://www.w3schools.com/html/mov_bbb.ogg" type="video/ogg">
      Your browser does not support the video tag.
</video>
<br/>
<input type="button" value="Get Total Time" onclick="gettime();" />

Upvotes: 1

Related Questions