ios - HTML5 video for iPhone / iPad. How to detect connection speed? -
i need stream video in safari iphone/ipad best possible quality.
i created 2 video files: 1 in low-quality slow 3g speed, 1 in hi-quality wifi broadband streaming. noticed apps (youtube example) able detect if mobile device running 3g or wifi, , select small sized video rather hi-quality video.
now dom / javascript code, $v value replaced php , contains video filename:
<video id="thevideo" src="streaming/video_<?=$v ?>.m4v" width="600" height="360" width="640" height="360" preload="preload" controls="controls" autoplay="autoplay"> flowplayer/video<?=$v ?>.m4v </video> <script type="text/javascript"> var myvideo = document.getelementbyid("thevideo"); myvideo.load(); myvideo.play(); </script>
can write in javascript / webkit able detect connection mode?
thanks all.
- i assuming in own application:
you use apple's reachability determine connection type in application before sending uiwebview's request. can modify request's url adding query:
//determine connection type via reachability myurlstring = [myurlstring stringbyappendingstring:[nsstring stringwithformat:@"?conntype=%@", *conntypestring]]; //then send request page.
then, parse url query in php determine video url should used.
- if not, need test connection speed via third-party javascript or php script.
example: http://jan.moesen.nu/code/php/speedtest/index.php?numkb=512
Comments
Post a Comment