Fix removing the meta files when navigating to a new video (#2344)
This commit is contained in:
parent
10f0af1efa
commit
35dcdbac10
|
@ -29,11 +29,11 @@ export default Vue.extend({
|
||||||
'watch-video-recommendations': WatchVideoRecommendations
|
'watch-video-recommendations': WatchVideoRecommendations
|
||||||
},
|
},
|
||||||
beforeRouteLeave: function (to, from, next) {
|
beforeRouteLeave: function (to, from, next) {
|
||||||
this.handleRouteChange()
|
this.handleRouteChange(this.videoId)
|
||||||
window.removeEventListener('beforeunload', this.handleWatchProgress)
|
window.removeEventListener('beforeunload', this.handleWatchProgress)
|
||||||
next()
|
next()
|
||||||
},
|
},
|
||||||
data: function() {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
firstLoad: true,
|
firstLoad: true,
|
||||||
|
@ -144,13 +144,13 @@ export default Vue.extend({
|
||||||
hideVideoLikesAndDislikes: function () {
|
hideVideoLikesAndDislikes: function () {
|
||||||
return this.$store.getters.getHideVideoLikesAndDislikes
|
return this.$store.getters.getHideVideoLikesAndDislikes
|
||||||
},
|
},
|
||||||
theatrePossible: function() {
|
theatrePossible: function () {
|
||||||
return !this.hideRecommendedVideos || (!this.hideLiveChat && this.isLive) || this.watchingPlaylist
|
return !this.hideRecommendedVideos || (!this.hideLiveChat && this.isLive) || this.watchingPlaylist
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
$route() {
|
$route() {
|
||||||
this.handleRouteChange()
|
this.handleRouteChange(this.videoId)
|
||||||
// react to route changes...
|
// react to route changes...
|
||||||
this.videoId = this.$route.params.id
|
this.videoId = this.$route.params.id
|
||||||
|
|
||||||
|
@ -220,14 +220,14 @@ export default Vue.extend({
|
||||||
window.addEventListener('beforeunload', this.handleWatchProgress)
|
window.addEventListener('beforeunload', this.handleWatchProgress)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
changeTimestamp: function(timestamp) {
|
changeTimestamp: function (timestamp) {
|
||||||
this.$refs.videoPlayer.player.currentTime(timestamp)
|
this.$refs.videoPlayer.player.currentTime(timestamp)
|
||||||
},
|
},
|
||||||
toggleTheatreMode: function() {
|
toggleTheatreMode: function () {
|
||||||
this.useTheatreMode = !this.useTheatreMode
|
this.useTheatreMode = !this.useTheatreMode
|
||||||
},
|
},
|
||||||
|
|
||||||
getVideoInformationLocal: function() {
|
getVideoInformationLocal: function () {
|
||||||
if (this.firstLoad) {
|
if (this.firstLoad) {
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
}
|
}
|
||||||
|
@ -535,7 +535,7 @@ export default Vue.extend({
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
getVideoInformationInvidious: function() {
|
getVideoInformationInvidious: function () {
|
||||||
if (this.firstLoad) {
|
if (this.firstLoad) {
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
}
|
}
|
||||||
|
@ -967,7 +967,11 @@ export default Vue.extend({
|
||||||
this.playNextCountDownIntervalId = setInterval(showCountDownMessage, 1000)
|
this.playNextCountDownIntervalId = setInterval(showCountDownMessage, 1000)
|
||||||
},
|
},
|
||||||
|
|
||||||
handleRouteChange: async function () {
|
handleRouteChange: async function (videoId) {
|
||||||
|
// if the user navigates to another video, the ipc call for the userdata path
|
||||||
|
// takes long enough for the video id to have already changed to the new one
|
||||||
|
// receiving it as an arg instead of accessing it ourselves means we always have the right one
|
||||||
|
|
||||||
clearTimeout(this.playNextTimeout)
|
clearTimeout(this.playNextTimeout)
|
||||||
clearInterval(this.playNextCountDownIntervalId)
|
clearInterval(this.playNextCountDownIntervalId)
|
||||||
|
|
||||||
|
@ -977,14 +981,13 @@ export default Vue.extend({
|
||||||
const player = this.$refs.videoPlayer.player
|
const player = this.$refs.videoPlayer.player
|
||||||
|
|
||||||
if (player !== null && !player.paused() && player.isInPictureInPicture()) {
|
if (player !== null && !player.paused() && player.isInPictureInPicture()) {
|
||||||
const playerId = this.videoId
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
player.play()
|
player.play()
|
||||||
player.on('leavepictureinpicture', (event) => {
|
player.on('leavepictureinpicture', (event) => {
|
||||||
const watchTime = player.currentTime()
|
const watchTime = player.currentTime()
|
||||||
if (this.$route.fullPath.includes('/watch')) {
|
if (this.$route.fullPath.includes('/watch')) {
|
||||||
const routeId = this.$route.params.id
|
const routeId = this.$route.params.id
|
||||||
if (routeId === playerId) {
|
if (routeId === videoId) {
|
||||||
const activePlayer = $('.ftVideoPlayer video').get(0)
|
const activePlayer = $('.ftVideoPlayer video').get(0)
|
||||||
activePlayer.currentTime = watchTime
|
activePlayer.currentTime = watchTime
|
||||||
}
|
}
|
||||||
|
@ -1000,23 +1003,23 @@ export default Vue.extend({
|
||||||
if (this.removeVideoMetaFiles) {
|
if (this.removeVideoMetaFiles) {
|
||||||
const userData = await this.getUserDataPath()
|
const userData = await this.getUserDataPath()
|
||||||
if (this.isDev) {
|
if (this.isDev) {
|
||||||
const dashFileLocation = `static/dashFiles/${this.videoId}.xml`
|
const dashFileLocation = `static/dashFiles/${videoId}.xml`
|
||||||
const vttFileLocation = `static/storyboards/${this.videoId}.vtt`
|
const vttFileLocation = `static/storyboards/${videoId}.vtt`
|
||||||
// only delete the file it actually exists
|
// only delete the file it actually exists
|
||||||
if (fs.existsSync('static/dashFiles/') && fs.existsSync(dashFileLocation)) {
|
if (fs.existsSync(dashFileLocation)) {
|
||||||
fs.rmSync(dashFileLocation)
|
fs.rmSync(dashFileLocation)
|
||||||
}
|
}
|
||||||
if (fs.existsSync('static/storyboards/') && fs.existsSync(vttFileLocation)) {
|
if (fs.existsSync(vttFileLocation)) {
|
||||||
fs.rmSync(vttFileLocation)
|
fs.rmSync(vttFileLocation)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const dashFileLocation = `${userData}/dashFiles/${this.videoId}.xml`
|
const dashFileLocation = `${userData}/dashFiles/${videoId}.xml`
|
||||||
const vttFileLocation = `${userData}/storyboards/${this.videoId}.vtt`
|
const vttFileLocation = `${userData}/storyboards/${videoId}.vtt`
|
||||||
|
|
||||||
if (fs.existsSync(`${userData}/dashFiles/`) && fs.existsSync(dashFileLocation)) {
|
if (fs.existsSync(dashFileLocation)) {
|
||||||
fs.rmSync(dashFileLocation)
|
fs.rmSync(dashFileLocation)
|
||||||
}
|
}
|
||||||
if (fs.existsSync(`${userData}/storyboards/`) && fs.existsSync(vttFileLocation)) {
|
if (fs.existsSync(vttFileLocation)) {
|
||||||
fs.rmSync(vttFileLocation)
|
fs.rmSync(vttFileLocation)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue