mozilla
Your Search Results

    MediaRecorder.onstop

    The MediaRecorder.onstop event handler (part of the MediaRecorder API) handles the stop event, allowing you to run code in response to media recording via a MediaRecorder being stopped.

    The stop event is thrown either as a result of the MediaRecorder.stop() method being invoked, or when the media stream being captured ends. In each case, the stop event is preceded by a dataavailable event, making the Blob captured up to that point available for you to use in your application.

    Syntax

    attribute EventHandler       onstop;

    Example

    if (navigator.getUserMedia) {
       console.log('getUserMedia supported.');
       navigator.getUserMedia (
          // constraints - only audio needed for this app
          {
             audio: true
          },
    
          // Success callback
          function(stream) {
               var mediaRecorder = new MediaRecorder(stream);
    
               record.onclick = function() {
                   mediaRecorder.start();
                   console.log("recorder started");
               }
    
               stop.onclick = function() {
                   mediaRecorder.stop();
                   console.log("recorder stopped");
               }
    
               mediaRecorder.onstart = function() {
                 // do something in response to
                 // recording being started
               }
    
               mediaRecorder.onstop = function() {
                 // do something in response to
                 // recording being stopped
               }
    
               ...

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
    Basic support

    Not supported

    25.0 (25.0) [1] Not supported Not supported Not supported
    Feature Android Firefox Mobile (Gecko) Firefox OS IE Phone Opera Mobile Safari Mobile
    Basic support Not supported 25.0 (25.0) [1] 1.3 Not supported Not supported Not supported

    [1] The current Gecko implementation currently only supports audio recording.

    Specifications

    Specification Status Comment
    MediaStream Recording Editor's Draft  

    See also

    Document Tags and Contributors

    Contributors to this page: kscarfone, teoli, chrisdavidmills
    Last updated by: teoli,