我需要在Safari中为iPhone/iPad播放一段尽可能高质量的视频。
我创建了两个视频文件:一个在低质量的慢3G速度,一个在高质量的WiFi宽带流。我注意到一些应用程序(例如YouTube)能够检测移动设备是由3G还是WiFi运行,所以选择一个小尺寸的视频而不是高质量的视频。
现在是我的DOM / Javascript代码,$v值被PHP替换,并包含视频文件名:
<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>我能用Javascript / Webkit写一些能够检测到连接模式的东西吗?
多亏了所有人。
发布于 2010-11-15 14:43:13
在发送UIWebView请求之前,您可以使用苹果的可达性来确定应用程序中的连接类型。可以通过添加查询来修改请求的URL:
//determine the connection type via Reachability
myURLString = [myURLString stringByAppendingString:[NSString stringWithFormat:@"?conntype=%@", *connTypeString]];
//then send the request for the page.然后,解析PHP中的URL查询,以确定应该使用的视频URL。
示例:http://jan.moesen.nu/code/php/speedtest/index.php?numKB=512
发布于 2010-11-15 14:44:11
您需要加载某种文档来测试连接速度。
一个例子-- http://alexle.net/archives/257
https://stackoverflow.com/questions/4185266
复制相似问题