回覆 10# 7h1r733n


但其他機android, desktop都無事。

個getresource.php 會check client有無login先用php readmp4() function gen.返條片出黎XD
  1. <?php

  2. $path = 'file.mp4';

  3. $size=filesize($path);

  4. $fm=@fopen($path,'rb');
  5. if(!$fm) {
  6.   // You can also redirect here
  7.   header ("HTTP/1.0 404 Not Found");
  8.   die();
  9. }

  10. $begin=0;
  11. $end=$size;

  12. if(isset($_SERVER['HTTP_RANGE'])) {
  13.   if(preg_match('/bytes=\h*(\d+)-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches)) {
  14.     $begin=intval($matches[0]);
  15.     if(!empty($matches[1])) {
  16.       $end=intval($matches[1]);
  17.     }
  18.   }
  19. }

  20. if($begin>0||$end<$size)
  21.   header('HTTP/1.0 206 Partial Content');
  22. else
  23.   header('HTTP/1.0 200 OK');

  24. header("Content-Type: video/mp4");
  25. header('Accept-Ranges: bytes');
  26. header('Content-Length:'.($end-$begin));
  27. header("Content-Disposition: inline;");
  28. header("Content-Range: bytes $begin-$end/$size");
  29. header("Content-Transfer-Encoding: binary\n");
  30. header('Connection: close');

  31. $cur=$begin;
  32. fseek($fm,$begin,0);

  33. while(!feof($fm)&&$cur<$end&&(connection_status()==0))
  34. { print fread($fm,min(1024*16,$end-$cur));
  35.   $cur+=1024*16;
  36.   usleep(1000);
  37. }
  38. die();
複製代碼

TOP

回覆  7h1r733n


但其他機android, desktop都無事。

個getresource.php 會check client有無login先用php ...
iambenzhk 發表於 2017-6-24 02:07

你呢個file.. windows都play唔到..

TOP

回覆 12# 7h1r733n


php program黎XD file放哂係web server到><

TOP

本帖最後由 7h1r733n 於 2017-6-24 05:49 編輯
回覆  7h1r733n


php program黎XD file放哂係web server到>
iambenzhk 發表於 2017-6-24 04:15


我知.. 我話你個file... o系chrome都play唔到..
根本你果個php就唔work.. 一play就stop...

算啦.. 等叔叔幫吓你啦.. 助人為快樂之本...
  1. <?php
  2. $file = "file.m4a";
  3. $size = filesize( $file ) ;

  4. header( "Accept-Ranges: bytes" ) ;
  5. $handle = fopen($file, 'rb');

  6. if ($handle === false)
  7.         return false;


  8. if( isset( $_SERVER['HTTP_RANGE'] ) ) {
  9.         $r=explode('=', $_SERVER['HTTP_RANGE'])[1];
  10.         list($start, $end) = explode('-', $r);
  11.         header('HTTP/1.1 206 Partial Content');
  12.         if(stripos($_SERVER['HTTP_USER_AGENT'],"iPod") || stripos($_SERVER['HTTP_USER_AGENT'],"iPhone") ||  stripos($_SERVER['HTTP_USER_AGENT'],"iPad")){
  13.              header('Content-Length: ' . ($end - $start +1));
  14.              header('Content-Range: bytes ' . $r . '/' . $size);
  15.         }else
  16.                         header('Content-Range: bytes '.$start.'-'.($size - 1).'/'.$size);
  17.                  
  18.         fseek($handle, $start);
  19. }else
  20.         header('Content-Length: ' . $size);


  21. header('Content-type: video/mp4');
  22. header('Etag: "' . md5( $_SERVER["REQUEST_URI"] ) . $size . '"' );
  23. header("Last-Modified: " . gmdate( "D, d M Y H:i:s", filemtime($file)) . " GMT");

  24. @ob_end_clean();
  25. while (!feof($handle) && connection_status() == 0 && !connection_aborted()) {
  26. set_time_limit(0);
  27. $buffer = fread($handle,16384);
  28. echo $buffer;
  29. @flush();
  30. @ob_flush();
  31. }
  32. fclose($handle);
  33. exit(0);
複製代碼

TOP

回覆 14# 7h1r733n


Etag係咩黎?@@ 點解要用md5加密佢?@@ 我係google search左幾日無人咁做XD

Thanks 大師兄, 我一陣試下

TOP

回覆  7h1r733n


Etag係咩黎?@@ 點解要用md5加密佢?@@ 我係google search左幾日無人咁做XD

Thanks 大師 ...
iambenzhk 發表於 2017-6-24 12:01


Etag
http://blog.csdn.net/21aspnet/article/details/6604789

TOP

回覆 16# 7h1r733n


多謝你, 又學到新野, 要星期一返到office先試到, 有野唔明再問你-v- 好感激!!!!!

TOP