ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

android – 可以在iOS设备上强制HTML5视频预加载吗?

2019-07-06 11:36:26  阅读:176  来源: 互联网

标签:android ios video-streaming html5-video preload


我发现有很多网站和参考资料证实,在Android和iOS移动设备上,HTML5视频preload =’auto’标签被故意忽略,浏览器等待用户手动按下播放按钮.

有没有办法可以推翻这种行为?

我们的情况是,我们计划让iPad在封闭的内联网WiFi系统上运行,其中蜂窝网络数据收费肯定不会成为问题.我们有视频文件,一旦页面加载,需要自动跳转到特定的播放位置.它在Windows,Linux或MacOS上的Chrome上运行得非常出色,但iOS却没有.

iOS或Android中是否有允许“预加载”的设置,就像在其他平台上一样?

或者,我已经在页面上进行了JavaScript和jQuery.是否有任何调用可以说服浏览器预加载视频,即使preload =’auto’没有?

我在http://www.stuartbruce.co.uk/editreader/javascript_video_test上放了一个测试页面来说明会发生什么.在Chrome上,在除iOS之外的所有平台上,视频会自动跳到镜头3.在iOS上,没有任何反应.

Apple关于这个问题的专线在这里:
User Control of Downloads Over Cellular Networks
但他们称之为“用户控制下载”这一事实意味着这是用户可以选择改变的.但是,我看不到任何证据.可能吗?用户或iPad可以“选择加入”以允许preload =’auto’正常工作吗?

解决方法:

根据下面的更新/信息,如果您设置了静音属性,则应该可以执行此操作:

video.play();
video.addEventListener('canplay', function() {
    this.currentTime = 5;
});

New Policies for iOS文章表明:

By default, WebKit will have the following policies:

  • elements will now honor the autoplay attribute, for elements which meet the following conditions:
    • elements will be allowed to autoplay without a user gesture if their source media contains no audio tracks.
    • elements will also be allowed to autoplay without a user gesture.
    • If a element gains an audio track or becomes un-muted without a user gesture, playback will pause.
    • elements will only begin playing when visible on-screen such as when they are scrolled into the viewport, made
      visible through CSS, and inserted into the DOM.
    • elements will pause if they become non-visible, such as by being scrolled out of the viewport.
  • elements will now honor the play() method, for elements which meet the following conditions:
    • elements will be allowed to play() without a user gesture if their source media contains no audio tracks, or if their muted
      property is set to true.
    • If a element gains an audio track or becomes un-muted without a user gesture, playback will pause. elements will be
      allowed to play() when not visible on-screen or when out of the
      viewport.
    • video.play() will return a Promise, which will be rejected if any of these conditions are not met.
    • On iPhone, elements will now be allowed to play inline, and will not automatically enter fullscreen mode when
      playback begins.
    • elements without playsinline attributes will continue to require fullscreen mode for playback on iPhone.
    • When exiting fullscreen with a pinch gesture, elements without playsinline will continue to play inline.

标签:android,ios,video-streaming,html5-video,preload
来源: https://codeday.me/bug/20190706/1397010.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有