-2

Users are going to be uploading video contents to my WordPress site.

How do I reject content if more than 1 minute or 60 seconds. They will be uploading via html or ajax form. Which is better to achieve this, JavaScript or php?

grizzthedj
  • 7,131
  • 16
  • 42
  • 62
valucci
  • 39
  • 1
  • 9

1 Answers1

0

You can get the video duration like that:

var vid = document.getElementById("video");
var duration = document.getElementById("duration");

vid.addEventListener('loadedmetadata', function() {
    duration.innerHTML = vid.duration;
});
<div id="duration"></div>
<video src="http://media.w3.org/2010/05/sintel/trailer.mp4" width=300 height=200 id="video"></video>

Otherwise, to get the video duration when the user select the file in the File Browser, you can check the already answered question here: https://stackoverflow.com/a/29285597/1738016

Virax
  • 16
  • 1
  • 4