question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Struggling to load local files

See original GitHub issue

I’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:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Blunderchipscommented, Nov 17, 2020

@nklayman getting this issue on linux. media files are just missing. works when served but not when built.

image

0reactions
no-response[bot]commented, Sep 16, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found