Fix issue with videos not loading when running in dev mode

This commit is contained in:
PrestonN 2021-07-17 20:24:26 -04:00
parent 829366621a
commit d4953525b2
2 changed files with 25 additions and 10 deletions

4
.gitignore vendored
View File

@ -2,6 +2,10 @@
dist/electron/* dist/electron/*
storyboards/* storyboards/*
dashFiles/* dashFiles/*
static/dashFiles
static/storyboards
static/dashFiles/*
static/storyboards/*
dist/web/* dist/web/*
build/* build/*
!build/icons !build/icons

View File

@ -1007,12 +1007,16 @@ export default Vue.extend({
let fileLocation let fileLocation
let uriSchema let uriSchema
if (this.isDev) { if (this.isDev) {
fileLocation = `dashFiles/${this.videoId}.xml` fileLocation = `static/dashFiles/${this.videoId}.xml`
uriSchema = fileLocation uriSchema = `dashFiles/${this.videoId}.xml`
// if the location does not exist, writeFileSync will not create the directory, so we have to do that manually // if the location does not exist, writeFileSync will not create the directory, so we have to do that manually
if (!fs.existsSync('dashFiles/')) { if (!fs.existsSync('static/dashFiles/')) {
fs.mkdirSync('dashFiles/') fs.mkdirSync('static/dashFiles/')
} }
fs.rm(fileLocation, () => {
fs.writeFileSync(fileLocation, xmlData)
})
} else { } else {
fileLocation = `${userData}/dashFiles/${this.videoId}.xml` fileLocation = `${userData}/dashFiles/${this.videoId}.xml`
uriSchema = `file://${fileLocation}` uriSchema = `file://${fileLocation}`
@ -1020,8 +1024,10 @@ export default Vue.extend({
if (!fs.existsSync(`${userData}/dashFiles/`)) { if (!fs.existsSync(`${userData}/dashFiles/`)) {
fs.mkdirSync(`${userData}/dashFiles/`) fs.mkdirSync(`${userData}/dashFiles/`)
} }
fs.writeFileSync(fileLocation, xmlData)
} }
fs.writeFileSync(fileLocation, xmlData)
return [ return [
{ {
url: uriSchema, url: uriSchema,
@ -1081,20 +1087,25 @@ export default Vue.extend({
// Dev mode doesn't have access to the file:// schema, so we access // Dev mode doesn't have access to the file:// schema, so we access
// storyboards differently when run in dev // storyboards differently when run in dev
if (this.isDev) { if (this.isDev) {
fileLocation = `storyboards/${this.videoId}.vtt` fileLocation = `static/storyboards/${this.videoId}.vtt`
uriSchema = fileLocation uriSchema = `storyboards/${this.videoId}.vtt`
// if the location does not exist, writeFileSync will not create the directory, so we have to do that manually // if the location does not exist, writeFileSync will not create the directory, so we have to do that manually
if (!fs.existsSync('storyboards/')) { if (!fs.existsSync('static/storyboards/')) {
fs.mkdirSync('storyboards/') fs.mkdirSync('static/storyboards/')
} }
fs.rm(fileLocation, () => {
fs.writeFileSync(fileLocation, results)
})
} else { } else {
if (!fs.existsSync(`${userData}/storyboards/`)) { if (!fs.existsSync(`${userData}/storyboards/`)) {
fs.mkdirSync(`${userData}/storyboards/`) fs.mkdirSync(`${userData}/storyboards/`)
} }
fileLocation = `${userData}/storyboards/${this.videoId}.vtt` fileLocation = `${userData}/storyboards/${this.videoId}.vtt`
uriSchema = `file://${fileLocation}` uriSchema = `file://${fileLocation}`
fs.writeFileSync(fileLocation, results)
} }
fs.writeFileSync(fileLocation, results)
this.videoStoryboardSrc = uriSchema this.videoStoryboardSrc = uriSchema
}) })