Safari mp4 does not work with htaccess authentication

On the dev site, I tested mp4 files for playing html5 in safari. A native player downloads and plays mp4 files in order, even without the correct MIME type declaration. But, if I add AuthType Basic to my .htaccess, the files sometimes cannot play and sometimes play in the Quicktime player.

After logging in with a valid user, why does this directive stop playing mp4 files correctly?

+6
source share
6 answers

still have the same problem. some people solved it by adding mime types to their .htaccess file (didn't work for me):

AddType video/ogg .ogv AddType video/mp4 .mp4 AddType video/mp4 .mov AddType video/webm .webm 

at the moment I m, using the already mentioned "add Satisfy All" in htaccess (see code below):

 <FilesMatch mp4> Satisfy any order allow,deny allow from all </FilesMatch> 

this is not a solution, since files are now available if you know a direct link to files ... for my case, everything is still in order, but I look forward to a real working solution!

+8
source

I suspect this is due to the way the Safari media sandbox is played. It seems that the page is being authenticated, but the video file is considered as a completely separate request requiring its login. The second authentication request fails in certain configurations, and the migration freezes while waiting for credentials.

The only solution I found to be less than ideal is to specifically release mp4 files from authentication. Add the following .htaccess files to the site and mp4 files will be available without logging in.

Keep in mind that if someone knew the exact path to the video files, they could view the files without logging in.

 # Exempt movies from password protection to prevent extra login prompts <Files ~ "\.(mp4|m4v)"> AddType video/mp4 mp4 order allow,deny allow from all satisfy any </Files> 

Note. Tilda tells Apache to match at the end of the file name, not in the home directory.

I was able to recreate this behavior on Lion (10.7.5) with Safari 6.02. Mountain Lion (10.8.2) with Safari 6.02 introduced a second authentication window and played the video correctly.

The only thing I doubt is that for mp4 playback, you must explicitly specify the type of server mime server. The second rule of the .htaccess block will take care of this, just in case.

+8
source

I basically take what @longilong and @joemailer suggested, and made more complete for our purposes in .htaccess:

 AddType video/ogg .ogv AddType video/mp4 .mp4 AddType video/mp4 .mov AddType video/x-m4v .m4v AddType video/webm .webm # Exempt movies from password protection to prevent extra login prompts <Files ~ "\.(ogv|mp4|mov|m4v|webm)$"> order allow,deny allow from all satisfy any </Files> 
+4
source

The only work I found was to add the Satisfy All directive to the directory where the media is located. but of course it is potentially available outside the authenticated area. therefore, this is not an acceptable solution.

+2
source

I just think. but if you use basic authentication, the first thing that happens is that your server responds with 401 RESULT CODE. Then a browser window opens with username / password. The player may have trouble getting the right content. Try to figure out this Firefox and Firefox plugin to check your network access for checking. Perhaps you can solve the problem with first authentication.

0
source

I had the same problem. I'm not sure why this is the case, but I found a way to get Safari (I'm using version 6.0.2) to upload video files to a subdirectory of a password protected directory (htaccess authentication). It works if I add my credentials to the system keychain. I assume that resource requests are not sent with proper authentication. That's why Satisfy's solution works: resources no longer need authentication.

0
source

Source: https://habr.com/ru/post/889390/


All Articles