Jump to content

Help with adding a window alert to this script


Chrisj

Recommended Posts

The web cam recorder script that I'm working with has the "navigator', etc. code and the end of the script as shown below.
 
I tried to add this code, so people trying to use the webcam recorder in IE will see an alert dialog box(without success):
 
		    if (!navigator || !navigator.getUserMedia || !navigator.mediaDevices.getUserMedia) {
		           if (window.confirm('Your browser does not support WebVideo, try Google/Chrome'))
		    	   {
		    window.location.href='https://../index.php';
		    		} else {
		    		    show();
}
}

Maybe I've got something wrong. The window.confirm message still doesn't display in IE. Here's the script without the 'alert' code:

                <script>
		             const video = document.querySelector('video')
		             const startvideo = document.querySelector('.start')
		             const stopvideo = document.querySelector('.stop')
		             const upload = document.querySelector('.upload')
		             const initRecorder = stream => {
		             const recorder = new MediaRecorder(stream)
		             let blob
		               video.srcObject = stream
		               startvideo.removeAttribute('disabled')
		               video.addEventListener('loadedmetadata', () => {
		               video.play()
		               })
		               recorder.addEventListener('dataavailable', ({ data }) => {
		               video.srcObject = null
		               video.src = URL.createObjectURL(data)
		               // Create a blob from the data for upload
		               blob = new Blob([data], { type: 'video/webm' })
		               })
		 
		               startvideo.addEventListener('click', () => {
		               stopvideo.removeAttribute('disabled')
		               show()
		               reset()
		               start()
		               recorder.start()
		 
		 etc., etc, ............................
		 
		               navigator
		                 .mediaDevices
		                 .getUserMedia({ video: true })
		                 .then(initRecorder)
		                 .catch(console.error)
		 
         </script>
Any suggestions/enlightenment to get the 'alert'/confirm code to work with this script, will be appreciated.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.