Page 1 of 1
Playing local files with the VLC Web Plugin
Posted: 02 Aug 2012 17:28
by guidupuy
Hi everyone,
I'm currently building a site that lets users play local video files in the browser - just like VLC desktop, except in the browser.
I'm trying to simplify the action of adding files to the playlist - I am currently able to launch a movie from a text input (--> users writes the local file's path in the input field), but would very much like to be able to do so from a file input (<input type="file"> --> a much more natural way to go for the average user I think).
For security purposes, no browser will let me access the full path of a file selected via an file input. However, HTML5's File API will let me create an ObjectURL that points to the local file:
Code: Select all
file = $('#fileInput').get(0).files[0];
window.URL = window.webkitURL || window.URL;
var fileURL = window.URL.createObjectURL(file);
This produces a URL in the form:
Code: Select all
blob:http://localhost:6564/02dc860b-b77e-4c40-b62b-39096f9672b6
Sadly though, I can't get that URL to work as a valid, VLC-compatible MRL. Any idea why? What's the best way to go to let users select the file they want to play?
Re: Playing local files with the VLC Web Plugin
Posted: 06 Aug 2012 16:59
by guidupuy
Anybody found anything interesting?
Re: Playing local files with the VLC Web Plugin
Posted: 12 Aug 2012 10:40
by karelbilek
We did a nasty trick in our application.
You really can't load file name by javascript; however, you CAN read a file path by java applet.
So we added an additional java applet to our app (so now, we require both VLC plugin and Java. Hurray for open internet.)
Re: Playing local files with the VLC Web Plugin
Posted: 16 Aug 2012 16:31
by guidupuy
Damn. There's gotta be a better way...
Re: Playing local files with the VLC Web Plugin
Posted: 08 Oct 2012 00:53
by ForbiddenSoul
I am by far no pro, but what I am trying to accomplish is set individual files as VODs (Video On Demand) and then stream those from a browser. I imagine you could do the same, as when you set up VOD stream, the output path is a name of your choosing not necessarily the full path of the file. That would keep your current security settings and allow users to search base on the stream name.
Now I just need to get that damned embedded video plugin to work... (facepalm)
Re: Playing local files with the VLC Web Plugin
Posted: 25 Oct 2012 10:34
by jack.ting
I use following code to the get current directory name and append a subfolder name to it.
Maybe you can modify it to fit your needs.
Code: Select all
var vLoc = window.location.href ;
var vBase = vLoc.substr(0, vLoc.lastIndexOf("/", vLoc.lastIndexOf("/")-1)+1) + "Video/" ;
Re: Playing local files with the VLC Web Plugin
Posted: 13 Nov 2012 20:30
by Jochem
I need this too
But I don't want to make use of Java
Re: Playing local files with the VLC Web Plugin
Posted: 21 Dec 2012 18:57
by Tanoshimi
Bringing this topic up again, because I'm trying to do something similar, I think. Basically, I want to make a page that lists all the videos I have (locally, or on a server I run). I want that list to be links that when clicked on will play the video in a web embedded VLC player. The only way I've been able to play a video so far is to start that manually, and set VLC to Stream, then make a webpage with Target=localhost:8080. Since I don't know in advance what video is going to play, I obviously cannot use this approach. Not concerned about creating the page, per se, since it's going to be generated using php and the MySQL database that will give me the name of the movie, and the filename (location). So, I guess the basic question is, on the fly, how do I get VLC embedded into a webpage to play either:
file:///V:/Movies/My%20Movie.mkv
or
http://myServer.com/Movies/My%20Movie.mkv
I suppose, in the end, I'm looking for the web commands to Open a file, and start it streaming to the player I have embedded.
Re: Playing local files with the VLC Web Plugin
Posted: 05 Jan 2023 04:15
by ralbright
Has anyone gotten this to work? I would think that this would be easy. Trying to do it with a playlist is problematic as the ID number for a file adjusted between loads of VLC.... VERY ANNOYING.
Re: Playing local files with the VLC Web Plugin
Posted: 21 Jan 2023 17:07
by emcodem
@ralbright
Yeah got it to work (with some limitations) and no it is not easy to play non supported file formats in a browser in general.
In my case, i start vlc on the server that serves the webpage, encode to mpeg1 transport stream, rewrap with ffmpeg in order to avoid choppiness and send the output chunks from ffmpeg stdout directly to the client's open websocket session. The client also uses the same session to send seek/play etc.. commands to the open vlc process on the server, these commands are sent to vlc using the http interface. This way i avoid the clients need any local software and i don't need any hacks like additional ports to be opened between server and client.
Sure this technique is only for special applications that don't have many users online in parallel.