4

I am trying to get video to play in an HTML5 video tag using the following code:

<video id="video" width="768" height="432" controls>
    <source src="http://example.com/videos/example.mp4" type="video/mp4" />
</video>

Initially this was not working and I tracked it down to being an issue with Basic Authentication being enabled on the domain. However, if I try reenabling it in the .htaccess file as follows:

AuthUserFile /folder/containing/.htpasswd
AuthType Basic
AuthName "Members Area"
Require valid-user

The video player just stalls on the "Loading..." screen. Additionally if I try to access the file directly the playback in the browser reverts to using the quicktime controls and not the HTML5 controls you get when the authentication is turned off

At present the only solution I have is to remove / avoid requiring authentication in the folder containing the movie files for the site. However, I preferably need to keep the authentication enabled across the whole domain.

Therefore I am wondering if there is a way to serve video content which is located behind basic authentication.

Note: I am currently working to get this working in Safari and hence the focus towards the mp4 format.

Richard
  • 440
  • 1
  • 6
  • 15
  • I have got the similar question as well http://stackoverflow.com/questions/8852854/why-error-404-happens-when-i-access-mp4-file-by-http – NoWar Jan 13 '12 at 15:24

1 Answers1

0

You can use like this:

<video id="video" width="768" height="432" controls>
 <source src="http://username:password@domainname.com/video/video.mp4" type="video/mp4" />
</video>

This can help I think.

Praveen
  • 113
  • 6
  • Would this not require embedding a users password into the HTML markup? Not sure that would be a good idea from security point (or practical due to hashing) – Richard Aug 06 '13 at 18:32
  • Yes,in that scenario you shouldn't follow this type,the best way is that authentication given when the link is accessed. – Praveen Aug 07 '13 at 06:55