Re: [nodejs] html5 video not working with node.js

1,176 views
Skip to first unread message

Mark Hahn

unread,
Nov 12, 2012, 4:32:33 PM11/12/12
to nod...@googlegroups.com
> when I embed the video in the html file of node server

What do you mean by embed?  Surely you don't mean putting the video data in an actual .html file.

On Mon, Nov 12, 2012 at 1:16 PM, Yash Girdhar <yash.g...@gmail.com> wrote:
>
> I am trying to play a video using html5 video tag in chrome. when I play the video in a different file, containing just the video tag, the video is playing.but when I embed the video in the html file of node server, it is not.
>
> The other functionalities of the node server are working as expected( I have build an dynamic drawing board, and its working on the server).
>
> what can be the reason behind this?
>
> thank you
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

Yash Girdhar

unread,
Nov 12, 2012, 4:44:59 PM11/12/12
to nod...@googlegroups.com
actually, I have made a simple real time drawing board in node.js, using socket.io.Now, I want to embed real time video sync in the same file.
So, to start with I just added a video tag to the html file of the node.js server(I am attaching both the files for your reference), to make sure that   
at least I am able to play the video or not. nothing else changed in both server and html files.But, the video is not playing.I am able to play the video in the same file, by simply opening the html file in the browser or in the Localhost, BUT not on the node server. 
please help
app.js
index.html

Nathan Rajlich

unread,
Nov 12, 2012, 5:32:06 PM11/12/12
to nod...@googlegroups.com
Are you implementing the static file serving yourself? You're likely
not supporting the Range header and 206 partial responses, which HTML5
<video> tags expect to work properly. I'd recommend using connect's
static() middleware.

Ryan Schmidt

unread,
Nov 12, 2012, 6:56:13 PM11/12/12
to nod...@googlegroups.com

On Nov 12, 2012, at 16:32, Nathan Rajlich <nat...@tootallnate.net> wrote:

> Are you implementing the static file serving yourself?

The only route defined in app.js is:

app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});

Therefore "/" is the only route that will be served. If you also want to serve "/test.mp4", then you will need to define a route for that, or hook up some static middleware as Nate said.


Yash Girdhar

unread,
Nov 13, 2012, 5:00:53 AM11/13/12
to nod...@googlegroups.com

So, how can I serve the video in the same way as I am serving the file, i.e. defining a route for that.
right now, I am just giving the path of the video in the src attribute of video tag

Mark Hahn

unread,
Nov 13, 2012, 11:10:42 AM11/13/12
to nod...@googlegroups.com
BTW, serving files through node is slow and inefficient.  I would never think to send big video files through the V8 engine.  Use nginx on the front end, or another of several good options.

Nathan Rajlich

unread,
Nov 13, 2012, 11:48:02 AM11/13/12
to nod...@googlegroups.com
Seeing as though you're literally just serving regular files here, you
should really just use the .static() middleware. See:
https://github.com/visionmedia/express/blob/master/examples/static-files/index.js

On Tue, Nov 13, 2012 at 2:00 AM, Yash Girdhar <yash.g...@gmail.com> wrote:
>

Yash Girdhar

unread,
Nov 14, 2012, 11:40:21 AM11/14/12
to nod...@googlegroups.com
problem solved with ".static" :D
thanks a lot
Reply all
Reply to author
Forward
0 new messages