Created
December 6, 2013 17:42
-
-
Save kirankumaramruthaluri/7829020 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function onVideoFail(e) { | |
| console.log('webcam fail!', e); | |
| }; | |
| function hasGetUserMedia() { | |
| // Note: Opera is unprefixed. | |
| return !!(navigator.getUserMedia || navigator.webkitGetUserMedia || | |
| navigator.mozGetUserMedia || navigator.msGetUserMedia); | |
| } | |
| if (hasGetUserMedia()) { | |
| // Good to go! | |
| } else { | |
| alert('getUserMedia() is not supported in your browser'); | |
| } | |
| window.URL = window.URL || window.webkitURL; | |
| navigator.getUserMedia = navigator.getUserMedia || | |
| navigator.webkitGetUserMedia || | |
| navigator.mozGetUserMedia || | |
| navigator.msGetUserMedia; | |
| var video = document.querySelector('video'); | |
| var streamRecorder; | |
| var webcamstream; | |
| if (navigator.getUserMedia) { | |
| navigator.getUserMedia({audio: true, video: true}, function(stream) { | |
| video.src = window.URL.createObjectURL(stream); | |
| webcamstream = stream; | |
| // streamrecorder = webcamstream.record(); | |
| }, onVideoFail); | |
| } else { | |
| alert ('failed'); | |
| } | |
| function startRecording() { | |
| streamRecorder = webcamstream.record(); | |
| setTimeout(stopRecording, 10000); | |
| } | |
| function stopRecording() { | |
| streamRecorder.getRecordedData(postVideoToServer); | |
| } | |
| function postVideoToServer(videoblob) { | |
| var data = {}; | |
| data.video = videoblob; | |
| data.metadata = 'test metadata'; | |
| data.action = "upload_video"; | |
| jQuery.post("http://www.foundthru.co.uk/uploadvideo.php", data, onUploadSuccess); | |
| } | |
| function onUploadSuccess() { | |
| alert ('video uploaded'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
getting error on console webcamstream.record is not a function..Please help me out