Playing local files with the VLC Web Plugin

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
guidupuy
New Cone
New Cone
Posts: 4
Joined: 02 Aug 2012 11:58

Playing local files with the VLC Web Plugin

Postby guidupuy » 02 Aug 2012 17:28

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?

guidupuy
New Cone
New Cone
Posts: 4
Joined: 02 Aug 2012 11:58

Re: Playing local files with the VLC Web Plugin

Postby guidupuy » 06 Aug 2012 16:59

Anybody found anything interesting?

karelbilek
New Cone
New Cone
Posts: 2
Joined: 29 Nov 2011 15:53

Re: Playing local files with the VLC Web Plugin

Postby karelbilek » 12 Aug 2012 10:40

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.)

guidupuy
New Cone
New Cone
Posts: 4
Joined: 02 Aug 2012 11:58

Re: Playing local files with the VLC Web Plugin

Postby guidupuy » 16 Aug 2012 16:31

Damn. There's gotta be a better way...

ForbiddenSoul
New Cone
New Cone
Posts: 5
Joined: 08 Oct 2012 00:36

Re: Playing local files with the VLC Web Plugin

Postby ForbiddenSoul » 08 Oct 2012 00:53

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)

jack.ting
Blank Cone
Blank Cone
Posts: 35
Joined: 19 Jan 2011 04:04

Re: Playing local files with the VLC Web Plugin

Postby jack.ting » 25 Oct 2012 10:34

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/" ;

Jochem
New Cone
New Cone
Posts: 1
Joined: 13 Nov 2012 20:29

Re: Playing local files with the VLC Web Plugin

Postby Jochem » 13 Nov 2012 20:30

I need this too :( But I don't want to make use of Java

Tanoshimi
New Cone
New Cone
Posts: 1
Joined: 21 Dec 2012 18:44

Re: Playing local files with the VLC Web Plugin

Postby Tanoshimi » 21 Dec 2012 18:57

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.

ralbright
New Cone
New Cone
Posts: 3
Joined: 14 Nov 2022 03:42

Re: Playing local files with the VLC Web Plugin

Postby ralbright » 05 Jan 2023 04:15

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.

emcodem
Blank Cone
Blank Cone
Posts: 10
Joined: 05 Jul 2022 12:12

Re: Playing local files with the VLC Web Plugin

Postby emcodem » 21 Jan 2023 17:07

@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.


Return to “Web and scripting”

Who is online

Users browsing this forum: No registered users and 10 guests