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开发者_如何学Go 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.
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.
精彩评论