Help with function code

Currently working with this:

 <script><!--Recording Time Limit-->
var recordTimeout;

function stopClickHandler(evt) {
    clearTimeout(recordTimeout);
}

function startClickHandler(evt) {
    stopClickHandler();
    recordTimeout = setTimeout(recLimit,3000);
}

var recLimit;

function recLimit(){
stopvideo.trigger("click");
}

document.querySelector(".start").addEventListener('click', startClickHandler);
document.querySelector(".stop").addEventListener('click', stopClickHandler);
</script>

On the Console I see:
“Uncaught TypeError: stopvideo.trigger is not a function at recLimit (webcam.html:259)”

I’m trying to add a time limit on recording, with this script that works successfully:

```
<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()
     // Get the video element with id="myVideo"
    document.getElementsByTagName("span")[0].removeAttribute("class")
    document.getElementsByTagName("span")[0].setAttribute("class", "colorred")
    //document.getElementById("demo").innerHTML ="Recording...."
            })

    stopvideo.addEventListener('click', () => {
              upload.removeAttribute('disabled')
              recorder.stop()
              stop()
        document.getElementsByTagName("span")[0].removeAttribute("class")
        document.getElementsByTagName("span")[0].setAttribute("class", "colorgreen")
               
              video.setAttribute("controls","controls")
                        })

        // Upload the video blob as form data ............................
              upload.addEventListener('click', () => {
              uploadBlob(blob)
            })
          }

           ///////////////////////////////////////////////////
              //Reset the Camera
              function resetCamera(){
              location.reload();
               }
/////////////////////////////////////////////////////////

         //   uploading functionality ....
```

Any help is appreciated. I look forward to any assistance

what makes you think trigger would be a function? Just crtl+f trigger here and you won’t find any clue on that.

Thanks for your reply.

I’m not sure what you mean by “Just crtl+f trigger here and you won’t find any clue on that”, but I am hoping to get some help with my incorrect function.

Any additional guidance is appreciated

What guidance do you expexct when ignoring questions of the people here?

what makes you think trigger would be a function?

I just hit ctrl+f on my keyboard, type in “trigger” and dont get anything that leads to that conclusion, but confirms the error message you get

1 Like

what makes you think trigger would be a function?
Obviously I am wrong. I researched click and trigger functions and thought it was correct

Any other help is welcomed

Sponsor our Newsletter | Privacy Policy | Terms of Service