我已经能够使用Video.js动态加载视频,但我听说Video.js也支持mp3播放。我有这个功能来测试...
openMediaModal: function(type, src) {
//set up modal
var modal;
//if video...
if (type == 'video') {
modal = '<div class="modal-wrapper media '+type+'"><div class="modal">';
modal += '<video id="modal-player" class="video-js vjs-default-skin vjs-big-play-centered" controls preload="auto" width="640" height="264" poster="http://video-js.zencoder.com/oceans-clip.png">';
modal += '<source src="'+src+'" type="video/mp4" />';
modal += '</video>';
modal += '</div></div>';
} else if (type == 'audio') {
modal = '<audio id="modal-player" controls>';
modal += '<source src="'+src+'" type="audio/mpeg">';
modal += '</audio>';
} else if (type == "flash") {
}
//append modal to page
crc.body.append(modal);
//init video
videojs("modal-player", {}, function(){
// Player (this) is initialized and ready.
});
},
视频工作正常,但音频会引发错误。如何加载mp3以动态播放?它似乎没有记录。感谢。