【问题标题】:HTML5 video for iPhone / iPad. How to detect connection speed?适用于 iPhone / iPad 的 HTML5 视频。如何检测连接速度?
【发布时间】:2010-11-15 14:27:44
【问题描述】:

我需要在 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 编写一些能够检测连接模式的东西吗?

谢谢大家。

【问题讨论】:

    标签: html ios video-streaming


    【解决方案1】:

    您必须加载某种文档来测试您的连接速度。

    一个例子——http://alexle.net/archives/257

    【讨论】:

      【解决方案2】:
      • 我假设这将在您自己的应用程序中:

      在发送 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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-05-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-03-04
        • 2011-10-30
        相关资源
        最近更新 更多