html - 适用于iPhone/iPad的HTML5视频。如何检测连接速度?

标签 html ios video-streaming

我需要在iPhone / iPad的Safari中以最佳质量流式传输视频。

我创建了2个视频文件:一个为低质量的视频文件,以降低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中编写能够检测连接模式的内容吗?

谢谢大家。

最佳答案

  • 我假设这将在您自己的应用程序中:

  • 在发送UIWebView的请求之前,可以使用Apple的Reachability确定应用程序中的连接类型。您可以通过添加查询来修改请求的URL:
    //determine the connection type via Reachability
    
    myURLString = [myURLString stringByAppendingString:[NSString stringWithFormat:@"?conntype=%@", *connTypeString]];
    
    //then send the request for the page.
    

    然后,解析PHP中的URL查询以确定应使用的视频URL。
  • 如果没有,则需要通过第三方Javascript或PHP脚本测试连接速度。

  • 示例:http://jan.moesen.nu/code/php/speedtest/index.php?numKB=512

    关于html - 适用于iPhone/iPad的HTML5视频。如何检测连接速度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4185266/

    相关文章:

    ios - CNContactPickerViewController 仅检索选定的项目

    iphone - 呈现模态视图总是失败

    html - 如何左对齐 Vimeo 嵌入

    javascript - 处理多个 div 中特定 div 的事件

    iphone - 使用 CGRectMake 移动 subview 会导致崩溃

    c# - WebAPI PushStreamContent 远程主机关闭连接

    udp - 在 Gstreamer 上流式传输 MP4 视频文件

    html - 具有后备功能的响应式 <picture> 图片

    javascript - 移相器 : destroying text after a fixed number of seconds

    javascript - 如何在浏览器中解析mpeg2ts?