Skip to content

Commit

Permalink
Properly cancel and reset ongoing streams when unmounting
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
  • Loading branch information
skjnldsv authored and backportbot[bot] committed Apr 13, 2022
1 parent 04f332f commit d38b3c1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/components/Audios.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import Vue from 'vue'
import VuePlyr from '@skjnldsv/vue-plyr'
import '@skjnldsv/vue-plyr/dist/vue-plyr.css'
import logger from '../services/logger'
Vue.use(VuePlyr)
Expand All @@ -64,6 +65,8 @@ export default {
options() {
return {
autoplay: this.active === true,
// Used to reset the audio streams https://github.com/sampotts/plyr#javascript-1
blankVideo: '/blank.aac',
controls: ['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'settings'],
loadSprite: false,
}
Expand Down Expand Up @@ -94,6 +97,14 @@ export default {
})
},
beforeDestroy() {
// Force stop any ongoing request
logger.debug('Closing audio stream', { filename: this.filename })
this.$refs.audio.pause()
this.player.stop()
this.player.destroy()
},
methods: {
donePlaying() {
this.$refs.audio.autoplay = false
Expand Down
11 changes: 11 additions & 0 deletions src/components/Videos.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import Vue from 'vue'
import VuePlyr from '@skjnldsv/vue-plyr'
import '@skjnldsv/vue-plyr/dist/vue-plyr.css'
import logger from '../services/logger'
const liveExt = ['jpg', 'jpeg', 'png']
const liveExtRegex = new RegExp(`\\.(${liveExt.join('|')})$`, 'i')
Expand Down Expand Up @@ -85,6 +86,8 @@ export default {
options() {
return {
autoplay: this.active === true,
// Used to reset the video streams https://github.com/sampotts/plyr#javascript-1
blankVideo: '/blank.mp4',
controls: ['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'captions', 'settings', 'fullscreen'],
loadSprite: false,
}
Expand Down Expand Up @@ -115,6 +118,14 @@ export default {
})
},
beforeDestroy() {
// Force stop any ongoing request
logger.debug('Closing video stream', { filename: this.filename })
this.$refs.video.pause()
this.player.stop()
this.player.destroy()
},
methods: {
// Updates the dimensions of the modal
updateVideoSize() {
Expand Down

0 comments on commit d38b3c1

Please sign in to comment.