html5 视频无法在 iPad 中播放
我有一个视频标签,它在 Safari、Chrome 中工作正常,但在 iPad/iPhone 上不行。我做错了什么。
<a onclick="showVideoPlayer('http://www.mywebsite.com/videos/a video file.m4v')" id="video1" href="#">Play video</a>
js代码
function showVideoPlayer(videoSrc, showDownloadLink){
alert(videoSrc);
if(!videoSrc)
return;
$('div#overlay').show();
var $videoPlaceHolder = $('div#video-placeholder');
$videoPlaceHolder.show();
var $video = $videoPlaceHolder.find('video');
var winWidth = $(window).width() - 80;
var winHeight = $(window).height() - 120;
$video.attr('src', videoSrc);
$video.attr('width', winWidth + 'px');
$video.attr('height', winHeight + 'px');
$videoPlaceHolder.append($video);
if(showDownloadLink){
$('#video-placeholder .down').show();
}
}
I have a video tag, which working fine in Safari, Chrome but not on iPad/iPhone. Whats I am doing wrong.
<a onclick="showVideoPlayer('http://www.mywebsite.com/videos/a video file.m4v')" id="video1" href="#">Play video</a>
js code
function showVideoPlayer(videoSrc, showDownloadLink){
alert(videoSrc);
if(!videoSrc)
return;
$('div#overlay').show();
var $videoPlaceHolder = $('div#video-placeholder');
$videoPlaceHolder.show();
var $video = $videoPlaceHolder.find('video');
var winWidth = $(window).width() - 80;
var winHeight = $(window).height() - 120;
$video.attr('src', videoSrc);
$video.attr('width', winWidth + 'px');
$video.attr('height', winHeight + 'px');
$videoPlaceHolder.append($video);
if(showDownloadLink){
$('#video-placeholder .down').show();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
iOS 因对播放视频过于挑剔而臭名昭著。以下是需要检查的一些事项:
binary/octet-stream 在 iOS 上不起作用)
中使用
标记>,确保该值
type
属性与服务器提供的content-type
标头完全匹配 - 区分大小写。这些是我遇到的最常见的错误(我在在线视频平台工作) - 希望您的问题会像找出您缺少的要求一样简单。
iOS is notorious for being extra-fussy about playing back videos. Here's a few things to check for:
binary/octet-stream
will not work on iOS)<source type="foo" src="bar" />
tags within your<video />
, ensure that the value of thetype
attribute matches exactly thecontent-type
header supplied by the server - this is case-sensitive.Those are the most common errors I've come across (I work at an online video platform) - hopefully, your problem will be as simple as finding out which requirement you're missing.