js + php ¶ÁÈ¡¡¢²¥·ÅÊÓÆµÁ÷ ¼æÈÝfirefox£¬chrome£¬ie£¬macµÄsafari£¬iosµÄsafari£¬iosµÄ΢ÐÅä¯ÀÀÆ÷£¨Îļþ¶ÁÈ¡ÎļþÁ÷ƪ£©
ǰÌáÌõ¼þ£º
1¡¢Ñ¡ÓÃjwplayer6×÷Ϊǰ¶Ë²¥·ÅÆ÷£¨jwplayer6µÄ»ù±¾´úÂëºÍ×ÊÁÏ¿ÉÒÔµ½Æä¹ÙÍøÑ§Ï°²éѯ£¬±¾ÎÄÖнöΪ²¿·Ö´úÂ룩
2¡¢Ç°¶Ë¶¯Ì¬¼ÓÔØjwplayerÊÓÆµºÐ×Ó
3¡¢Ç°¶Ë¼ÓÔØµÄÊÓÆµ·ÇÊÓÆµµÄÎïÀíµØÖ·£¬¶øÊÇͨ¹ýphp¶ÁÈ¡µÄÊÓÆµÁ÷
4¡¢php¶ÁÈ¡µÄÊÓÆµÁ÷µÄÔ´ÎļþÊÇÒ»¸öÎïÀíµØÖ·µÄÎļþ
¼ÓÔØÊÓÆµºÐ×ӵIJ¿·Öjs´úÂë
function load_video_player(width,height,filename,type,size){ var player_w = width; var player_h = height; var isiphone; $.ajax({ type: 'POST', url: 'devicecontroller.php', data: 'islink='+islink, dataType:"JSON", async: false, success:function(data){ if(data.code == 1){ isiphone = data.data; }else{ isiphone = 0; } } }); var file_path = '/XXX/url?filename='+filename+'&type='+type+'&size='+size+'&isiphone='+isiphone; var player_wrap = [ '<div id="J_video_container" class="video_container hide">', '<div class="video_box">', '</div>', '</div>' ].join(''); var player_box = [ '<div id="Jwplayer_box">Loading player...</div>' ].join(''); if($('#J_video_container').length==0){ $('#J_video_main').append(player_wrap); } $('#J_video_container').css('height',player_h+'px'); if($('#Jwplayer_box').length==0){ $('#J_video_container .video_box').append(player_box); } $('.video_box').css({'width':player_w+'px','height':player_h+'px'}); $('#J_video_container').show(); jwplayer("Jwplayer_box").setup({ 'width': player_w, 'height': player_h, 'controlbar': 'bottom', "autostart":"true", 'provider': 'video', 'type': 'mp4', 'file': file_path }); }
function load_video_player(width,height,filename,type,size){ var player_w = width; var player_h = height; var isiphone; $.ajax({ type: 'POST', url: 'devicecontroller.php', data: 'islink='+islink, dataType:"JSON", async: false, success:function(data){ if(data.code == 1){ isiphone = data.data; }else{ isiphone = 0; } } }); var file_path = '/XXX/url?filename='+filename+'&type='+type+'&size='+size+'&isiphone='+isiphone; var player_wrap = [ '<div id="J_video_container" class="video_container hide">', '<div class="video_box">', '</div>', '</div>' ].join(''); var player_box = [ '<div id="Jwplayer_box">Loading player...</div>' ].join(''); if($('#J_video_container').length==0){ $('#J_video_main').append(player_wrap); } $('#J_video_container').css('height',player_h+'px'); if($('#Jwplayer_box').length==0){ $('#J_video_container .video_box').append(player_box); } $('.video_box').css({'width':player_w+'px','height':player_h+'px'}); $('#J_video_container').show(); jwplayer("Jwplayer_box").setup({ 'width': player_w, 'height': player_h, 'controlbar': 'bottom', "autostart":"true", 'provider': 'video', 'type': 'mp4', 'file': file_path }); }ÆäÖÐÇëÇó¼ì²éÉ豸ºÍä¯ÀÀÆ÷ÀàÐ͵Ädevicecontroller.php´úÂë
//json_encodeÖÐÎÄÂÒÂëÎÊÌâÐÞÕý function arrayRecursive(&$array){ foreach ($array as $key => $value) { if (is_array($value)) { arrayRecursive($array[$key]);//Èç¹ûÊÇÊý×é¾Í½øÐеݹé²Ù×÷ } else { if(is_string($value)){ $temp1= addslashes($value); $array[$key]= urlencode($temp1);//Èç¹ûÊÇ×Ö·û´®¾Íurlencode }else{ $array[$key] = $value; } } } } function JSON($result) { $array=$result; arrayRecursive($array);//ÏȽ«ÀàÐÍΪ×Ö·û´®µÄÊý¾Ý½øÐÐ urlencode $json = json_encode($array);//ÔÙ½«Êý×éת³ÉJSON return urldecode($json);//×îºó½«JSON×Ö·û´®½øÐÐurldecode } require_once("Mobile_Detect.php"); $detect = new Mobile_Detect(); if($detect->isiPhone() || $detect->isiPad()){ if($detect->isSafari() || $detect->isGenericBrowser()){//iphoneºÍipadÉϵÄsafari»òÕß΢ÐÅä¯ÀÀÆ÷ $iphone = 1; }else{ $iphone = 0; } }else{ $iphone = 0; } $data['code']=1; $data['data']=$iphone; echo JSON($data);¼ÓÔØÊÓÆµÁ÷µÄphp
$file_name = $_GET['filename']; $file_type = $_GET['type']; $file_size = $_GET['size']; $isiphone = $_GET['isiphone']; header("Content-type: ".$file_type); if(isset($_SERVER['HTTP_RANGE'])){ $http_range = $_SERVER['HTTP_RANGE']; $at = explode('=',$http_range); $at = explode('-',$at[1]); $start = $at[0]; if($at[1] == null){ $end = $file_size-1; }else{ $end = $at[1]; } $length = $end - $start + 1; if($isiphone==1){ $fp = @fopen($file, 'rb'); header("Accept-Ranges: 0-$length"); set_time_limit(0); fseek($fp,$start); header("Content-Range: bytes $start-$end/$file_size"); header("Content-Length: $length"); while(!feof($fp)){ echo fread($fp, $length); flush(); } exit; }else{ normal_download(); } }else{ normal_download(); } function normal_download(){ Header("Content-type: ".$file_type); Header('Content-Disposition: attachment; filename="'.$filename.'"'); Header("Content-Length: ".$file_size); readfile($filename); }
²¹³ä˵Ã÷£º
ÔÚjsÖÐÇëÇóÅжÏÒ»´ÎÉ豸£¬²¢Í¨¹ýjs´«µÝ¸øphp¶ÁÈ¡ÊÓÆµÁ÷£¬¶ø²»ÊÇÔÚphp¶Ë¶ÁÈ¡ÊÓÆµÁ÷ʱÿ´ÎÅжÏÉ豸£º
ÒòΪios safariÔÚµÚÒ»´Î£¨»áÉ趨$_SERVER['HTTP_RANGE']£©ÇëÇóµÄʱºò£¬ÄÜÅжϳöÊÇiosµÄsafariÉ豸
ÔÚµÚ¶þ´ÎÒÔ¼°Ö®ºóµÄÇëÇóʱ£¬ÎÞ·¨ÅжϳöÊÇiosµÄsafariÉ豸
ÍÆ¼öÐÅÏ¢
- ¡¾ÊÓÆµ²¥·Å¡¿JplayerÊÓÆµ²¥·ÅÆ÷µÄʹÓÃ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- php³£ÓÃÕýÔò±í´ïʽ
- phpÐÔÄܼà²âÄ£¿éXHProf
- ÈÃCI¿ò¼ÜÖ§³Öservice²ã
- ʹÓÃPHPÉú³É´øLOGOµÄ¸öÐÔ»¯¶þάÂëͼÏñ
- ¹ØÓÚCodeIgniterÄã¿ÉÄܲ»ÖªµÀµÄ5¸ö֪ʶµã
- Memcache ºÁÃë¼¶³¬Ê±¼°ÆäËû³£¼ûÎÊÌâ»ã×Ü
- [PHP±Ê¼Ç]PHPQueryÒ»¸ö´¦ÀíDOMµÄÀûÆ÷
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔØ½ø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- PHP»ñÈ¡Óû§µÄÕæÊµIP£¬²¢ÅжÏÊÇ·ñÄÚÍøIP
- PHP ´íÎóÈÕÖ¾ error_log
- ÀûÓÃbigpipe»úÖÆÊµÏÖÒ³ÃæÄ£¿éµÄÒì²½äÖȾ chunked¼¼Êõ
- php¿ØÖÆÎļþÏÂÔØËÙ¶È
- js + php ¶ÁÈ¡¡¢²¥·ÅÊÓÆµÁ÷ ¼æÈÝfirefox£¬c....
- ¡¾ÊÓÆµ²¥·Å¡¿JplayerÊÓÆµ²¥·ÅÆ÷µÄʹÓÃ
- UNICODE Óë UTF-8 µÄ¹ØÏµ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- phpʹÓÃmb_detect_encoding¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ