I have a vuejs component that streams an MP4 stream over http but once the component is destroyed the http connection stays open and keeps downloading content until i refresh the browser.
When the component is mounted i set a <video> tags src equal to the MP4 url, which in turn automatically opens the http connection to the MP4 and it starts downloading and displaying video, which is expected and desired. BUT when the component is destroyed in the destroyed() hook, the connection stays open and keeps downloading video.
I have tried to use XMLHttpRequest() to create the connection but thats not working either. Is there a way to essentially kill the http connection upon destroying the vue component?
vue component:
<template>
<video muted :src="mp4Src"></video>
</template>
export default {
data() {
return {
mp4Src: null
}
},
mounted() {
this.mp4Src = 'http://my-stream.com/123.mp4';
},
destroyed() {
// Setting this to this.mp4Src = ''; doesnt work
console.log('How to destroying stream?');
}
}