ios 不会自动加载 音/视频,普通 静态资源服务器 不会加速 音/视频
所以,preload autoplay 傻傻不触发,loadstart 等事件也不触发
当然,有服务器支持,最好不过!
video
// iphone-inline-video.min.js
<video id="video"
preload="auto"
playsinline
webkit-playsinline
x-webkit-airplay
x5-video-player-type="h5"
@click="click2PlayVideo"
src="([$baseurl])/video/xxx-small.mp4?([$version])"
poster="([$baseurl])/img/poster-0.jpg?([$version])">
</video>
var video = $('#video')[0];
enableInlineVideo(video);
audio
// 音频预加载,还可以做一下兼容
// musicUrl
getAudioBlob: function() {
var that = this;
var xhr = new XMLHttpRequest();
xhr.responseType = 'blob';
xhr.open("get", baseurl + '/music/lancome.mp3?999', true);
xhr.onload = function() {
console.log(this.response);
that.bIsLoaded = true;
that.musicUrl = URL.createObjectURL(this.response);
};
xhr.onerror = function(err) {
console.log(err);
};
xhr.send();
}
网友评论