angularjs - Get duration of local video selected using angular -


is possible validate duration of local video user has selected using file input in angular?

i have following html binds selected video model.

<input type="file" ng-model='video.videotoupload' accept="video/*" required> 

the properties of video in controller include filesize , filetype no duration. want avoid overhead of submitting video web server validate duration.

this not pure fit angular-- works!! have tried mp4 format.

var myvideos = [];  window.url = window.url || window.webkiturl;  function setfileinfo(files) {    myvideos.push(files[0]);    var video = document.createelement('video');    video.preload = 'metadata';    video.onloadedmetadata = function() {      window.url.revokeobjecturl(this.src)      var duration = video.duration;      myvideos[myvideos.length-1].duration = duration;      updateinfos();    }    video.src = url.createobjecturl(files[0]);;  }    function updateinfos(){        document.queryselector('#infos').innerhtml="";    for(i=0;i<myvideos.length;i++){        document.queryselector('#infos').innerhtml += "<div>"+myvideos[i].name+" duration: "+myvideos[i].duration+'</div>';       }    }
<div id="input-upload-file" class="box-shadow">    <span>- try upload -</span>     <input type="file" class="upload" id="fileup" name="fileupload" onchange="setfileinfo(this.files)">  </div>  <div id="infos"></div>

happy helping!


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -