alex8088 / quick-start

An easy way to start a front-end project.
MIT License
248 stars 34 forks source link

Unable to play local video #25

Open GregorGabric opened 7 months ago

GregorGabric commented 7 months ago

Describe the bug

Even though I create the file handler and I registerSchemesAsPrivileged, the video still doesn't play while it starts playing with other templates

protocol.registerSchemesAsPrivileged([
  {
    scheme: 'app-file',
    privileges: {
      standard: true,
      secure: true,
      supportFetchAPI: true,
      stream: true
    }
  }
])

// inside app.whenReady()

protocol.handle('app-file', (request) => {
     // it never reaches this part
      console.log(request.url, 'HERE', request)
      return net.fetch(`file:///${decodeURI(request.url.slice('app-file://'.length))}`)
    })

 // inside render
 <video
        preload="auto"
        src="app-file:///users/gregor/Documents/movies/dji_1.MP4"
      />

Used Scaffolding

create-electron

Used Package Manager

npm

Validations

alex8088 commented 7 months ago

protocol.handle should use local path but not file protocol

GregorGabric commented 7 months ago

I don't understand sorry. Should it just be /users/and-so-on ?

alex8088 commented 7 months ago

net.fetch should be the local path

GregorGabric commented 7 months ago

protocol.handle never actually runs, the console.log never actually logs anything ever.

alex8088 commented 7 months ago

https://github.com/alex8088/electron-vite/issues/36

<script setup lang="ts">
const icon = 'app:///icon.png'
</script>

<template>
  <img :src="icon" />
</template>