Is there a way I can set a limitation of the videos duration using HTML5, Javascript or PHP? Sort of like snapchat and vine
<p>I know HTML5 now has a getusermedia() where you can access their cameras. However, is there a way where I can set a limit to how long I want the recording to go for such as 30 seconds and then save it? Or even if there's a loop hole such as having a counter or something..</p>

<pre><code>   &lt;script&gt;
        var video = document.querySelector("#videoElement");
        navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia ||    navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia;
        if (navigator.getUserMedia) {       
        navigator.getUserMedia({video: true, audio: true}, handleVideo, videoError);
        }
        function handleVideo(stream) {
        video.src = window.URL.createObjectURL(stream);
        document.getElementById("videoElement").pause();
        }
        function videoError(e) {
        alert("There was an error with the video stream.\nCheck that your webcam is connected.");
        }
        function play()
        {
        var video = document.getElementById("videoElement");
        var music = document.getElementById("song");
           var button = document.getElementById("play");
           if (video.paused) {
              video.play();
              music.play();
              button.textContent = "Stop Recording";
           } else {
              video.pause();
              music.pause();
              button.textContent = "Continue Recording";
           }
        }
        function show()
        {
        document.getElementById("record").style.display="block";
        }
        &lt;/script&gt;
</code></pre>