I am developing a video player with electron. And I wanna have an ability to choose a video file from the file system and play it. The path could look like C://Users/.../...
for win. and /Users/../../
for OSX. So the problem is Chrome cannot use the file://
protocol and without the the protocol it's trying to load it from the current host. So is there a way to load a video from OS file system using electron or webpack?
Asked
Active
Viewed 1,553 times
2

Alon Adler
- 3,984
- 4
- 32
- 44

aGoodRussianGuy
- 173
- 1
- 1
- 11
-
Did you try using the path without the `file://` prefix ? For example: `src="C://Users/path/to/video.mp4"` – Alon Adler Jun 27 '17 at 19:02
-
Yeah, I tried, Chrome automatically adds `localhost` as host, so it tries to load it like `localhost:8080/C://Users/../` – aGoodRussianGuy Jun 28 '17 at 08:04
-
Weird, I'm accessing image files in my Electron app, after selecting their path from the electron `select-directory` dialog and using the returned path. Chrome never added `localhost` prefix in my app. Do you parse your files in the "Client Side" or in the Node side ? I'm using *Node's FS* (`var fs = require('fs')`) to parse them. Look at this [electron-video-player](https://github.com/RIAEvangelist/electron-video-player) app, I assume you'll find your answer there. – Alon Adler Jun 28 '17 at 09:35
1 Answers
0
You can allow the user choose the video, if this will meet your needs, using:
<input type="file" accept="video/*"/>
This works on chrome.
There is a nice working example in the fiddle in this answer: https://stackoverflow.com/a/9349984/334402

Mick
- 24,231
- 1
- 54
- 120