【问题标题】:on iPad http url in src attribute of html 5 video tag is not working在 iPad 上,html 5 视频标签的 src 属性中的 http url 不起作用
【发布时间】:2012-11-23 04:46:35
【问题描述】:

我无法在 ipad 上的 html 5 视频标签的 src 属性中使用 http url 加载视频。使用静态和动态方式来做到这一点。但是它在网络浏览器上工作正常。这是我的代码:

Static:

     <!DOCTYPE html>
    <html>
    <body>

    <video width="320" height="240" controls="controls">
      <source src="http://xyz.mp4" type="video/mp4">
Your browser does not support the video tag.
    </video>

    </body>
    </html>

动态:

function Video(){
           var html = "";
html += '<video id="someVideo" width="712" height="500" controls="controls" autoplay="autoplay">';
html += '<source src="http://xyz.mp4"  type="video/mp4" />';
html += '</video>';
$("#page33video2").html(html);

$('#someVideo').attr('src', 'http://xyz.mp4');
$('#someVideo')[0].load();


}

有没有办法在 html 5 视频标签的 src 属性中使用 http url 加载视频?

提前致谢。 维卡斯

【问题讨论】:

  • 你的意思是,你想动态改变视频的src吗?请清除..

标签: javascript css html


【解决方案1】:

如果你想动态设置视频的src,你可以这样做

<!DOCTYPE html> 
<html> 
<body> 
<video id="video1" style="display: none;">
</video>
<script>
function playVideo() {
document.getElementById("video1").style.display = "inline";
myVid=document.getElementById("video1");
myVid.src= "http://www.w3schools.com/tags/mov_bbb.mp4";
myVid.play();
}
</script> 
<p onclick="playVideo();">Click me to play</p>
It may take some time to load Video
</body> 
</html>

:)

【讨论】:

  • 嗨 Ameya,此代码不适用于 iPad。但是它在网络浏览器上运行良好。我想在 iPad 上使用 http url 设置 src。
  • @Vicky: - 我已经在我的 iPad 上检查了它的工作正常.. 但我必须等待视频下载,之后你可以再次点击“点击我播放”。播放视频。请告知您是否在做其他事情。
  • 嗨,Ameya,我正在 ePub3 中尝试此操作,但在 iPad 中无法通过此方法加载视频。 ePub3 不允许 video 标签在 src 属性中加载 http url 有什么限制吗?
  • 嗨,Ameya,我正在 ePub3 中尝试这个,并且在 iPad 的 iBooks 中没有通过这种方法加载视频。但是它在“Readium”上运行良好。 ePub3 不允许 video 标签在 iBooks 的 src 属性中加载 http url 有什么限制吗?
  • 我不知道什么是 ePub3,但我搜索并得到 ePub3 应该支持音频和视频标签,以及它支持 HTML5、CSS3。此链接可能会帮助您idpf.org/epub/30/spec/epub30-overview.html 并转到多媒体部分..
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-02-28
  • 2017-07-25
  • 2020-04-21
  • 2023-03-27
  • 1970-01-01
  • 2014-06-24
  • 1970-01-01
相关资源
最近更新 更多