Я использую PHP script для проверки запросов видео до их обслуживания. Этот script работает как на рабочем столе, так и в Safari и Chrome. Но на iOS я получаю сломанную кнопку воспроизведения.
Я уверен, что видео правильно закодировано для iPhone/iPad, потому что, когда я обращаюсь к нему напрямую, он работает так, как ожидалось.
Соответствующий PHP-код:
$file_name = 'test-video.mp4';
$file_size = (string)(filesize($file_name));
header('Content-Type: video/mp4');
header('Content-Length: '.$file_size);
readfile_chunked($file_name);
exit;
(readfile_chunked()
похож на readfile()
, но для очень больших файлов, найденных в комментариях на странице руководства PHP: http://php.net/manual/en/function.readfile.php В любом случае test-video.mp4
составляет всего ~ 5 МБ, что меньше предела памяти - и в этом случае я действительно могу заменить в нормальном readfile()
и произвести то же самое поведение.)
Заголовки, которые я получаю при прямом доступе к test-video.mp4
, следующие:
Accept-Ranges:bytes
Connection:Keep-Alive
Content-Length:5558749
Content-Type:video/mp4
Date:Sun, 27 Jun 2010 21:02:09 GMT
Etag:"1c04757-54d1dd-489944c5a6400"
Keep-Alive:timeout=10, max=30
Last-Modified:Tue, 22 Jun 2010 01:25:36 GMT
Server:Apache/2.2.15 (CentOS) mod_ssl/2.2.15 0.9.8l DAV/2 mod_auth_passthrough/2.1 FrontPage/5.0.2.2635
Заголовки PHP script:
Connection:Keep-Alive
Content-Disposition:inline; filename="test-video.mp4"
Content-Length:5558749
Content-Type:video/mp4
Date:Sun, 27 Jun 2010 21:03:32 GMT
Keep-Alive:timeout=10, max=15
Server:Apache/2.2.15 (CentOS) mod_ssl/2.2.15 0.9.8l DAV/2 mod_auth_passthrough/2.1 FrontPage/5.0.2.2635
X-Powered-By:PHP/5.2.13
Я пробовал много разных перестановок заголовков, даже точно их сопоставляя с запросами, безрезультатно.
Кто-нибудь успел обслуживать видео HTML5 через PHP, на iOS?
[Примечание. Я бы попытался использовать X-Sendfile, но сайт находится на общем хосте с очень ограниченным доступом.]
EDIT: Я читал, что iOS может быть чувствительным к расширениям файлов, поэтому я попытался настроить RewriteRule, который переписывает запросы MP4 обратно на мой оригинальный PHP script, но это не помогло либо.