2013-04-22 57 views
1

我想通過PHP流mp4視頻。我的應用程序從它存儲在塊中的位置加載視頻並提供相應的部分。使用這些標題:PHP視頻流到iPad

header("Content-Type: $contenttype"); 
header("Content-Length: $filesize"); 
header('Accept-Ranges: bytes'); 

它也可以在使用以下附加頭和outputing正確的字節請求服務的部分內容:

header('HTTP/1.1 206 Partial Content'); 
header("Content-Range: bytes $start-$end/$filesize"); 

流在Chrome中,並通過VLC的偉大工程,但將無法正常工作在iPad上。測試mp4文件被確認在ipad上工作。

有人有這個運氣嗎?任何建議將不勝感激!

+0

退房在http://stackoverflow.com/questions/5924061/using-php-to-output-an-mp4-video腳本,你有什麼照顧在http://stackoverflow.com/questions/24042894/php-ipad-does-not-play-mp4-videos-delivered-by-php-but-if-accessed-directly-it – 2014-06-07 15:32:34

回答

0

是的,它很容易做到。 不需要手動設置這些標頭。 讓服務器自動執行。

繼承人的工作腳本 -

ob_start(); 

if(isset($_SERVER['HTTP_RANGE'])) 
     $opts['http']['header']="Range: ".$_SERVER['HTTP_RANGE']; 

$opts['http']['method']= "HEAD"; 
$conh=stream_context_create($opts); 
$opts['http']['method']= "GET"; 
$cong= stream_context_create($opts); 
$out[]= file_get_contents($real_file_location_path_or_url,false,$conh); 
$out[]= $http_response_header; 
ob_end_clean(); 
array_map("header",$http_response_header); 
readfile($real_file_location_path_or_url,false,$cong);