Struggling to load local files
See original GitHub issueI’m trying to load an array of video files using the code below. It works with npm run serve
and builds with npm run electron:build
but the build does not load the files. I have tried lots of suggestions from #47 but none of them seem to work. I’m on OSX.
<template>
<div v-for="(element, index) in media" :key="index">
<div :class="{ hidden : index != currentIndex }">
<video ref="video" :src="getVideo(index)" type="video/mp4" preload="auto" @ended="videoEnded"></video>
</div>
</div>
<button @click="playPause">
<span v-if="!isPlaying">Play</span>
<span v-else>Pause</span>
</button>
</template>
export default {
name: "Test",
data() {
return {
media: ["video1.mp4", "video2.mp4", "video3.mp4", "video4.mp4"],
currentIndex: 0,
isPlaying: false,
};
},
methods: {
getVideo(index) {
return require("../assets/" + this.media[index]);
},
videoEnded() {
this.nextVideo();
},
nextVideo() {
this.pause();
this.currentIndex++;
this.play();
},
playPause() {
if (this.isPlaying) {
this.pause();
this.isPlaying = false;
} else {
this.play();
this.isPlaying = true;
}
},
play() {
this.$refs.video[this.currentIndex].play();
},
pause() {
if (this.$refs.video[this.currentIndex].readyState == 4) {
this.$refs.video[this.currentIndex].pause();
}
},
},
};
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Why is Chrome much slower at loading local files than online ...
Chrome is very slow to load some HTML pages/websites stored locally on my SSD. For example, if I download the NumPy documentation and...
Read more >Trouble Syncing Spotify Local Files? Here's How You Can Fix ...
Find the folder that holds the audio files you want to play and select it. Spotify will load your local files. Selecting audio...
Read more >Local files slow to load, won't sync to mobile
The local file I'm trying to download is on the bottom. Every other file has the check or plus sign to indicate if...
Read more >Is it really so hard to load a local JSON file? - Reddit
I'm working on a platformer game in HTML, and have the level data stored in a JSON file. It's right there, in the...
Read more >Why is Office 365 slow to load and open local files?
Perhaps this has something to do with OneDrive integration. Is there a way to stop the very slow loading the first file from...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@nklayman getting this issue on linux. media files are just missing. works when served but not when built.
This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don’t have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.