gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 18:03:18 25 4
gpt4 key购买 nike

我需要在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/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com