How to properly unload/destroy a VIDEO element

后端 未结 15 2147
闹比i
闹比i 2020-12-04 07:58

I\'m working on a realtime media browsing/playback application that uses objects in the browser for playback, when available.

I\'m using a

15条回答
  •  时光说笑
    2020-12-04 08:39

    My code did not use a element with a src tag, but instead used multiple children to set a video in multiple formats.

    To properly destroy and unload this video, I had to use a combination of multiple answers on this page, which resulted in:

    var videoElement = $('#my-video')
    videoElement[0].pause()  // Pause video
    videoElement.empty()     // Remove all  children
    videoElement.load()      // Load the now sourceless video
    delete videoElement      // The call mentioned in other answers
    videoElement.remove()    // Removing the video element altogether
    

    Hope this helps someone.

提交回复
热议问题