也许这个 GitHub 资源可以提供帮助。这提供了 JWPlayer 所需的完整 Javascript 堆栈。 JWPlayer 是免费的,带有水印。
你可以使用 JWPlayer(它也是开源的)
你的 main.js 文件的内容===============
// 将插件引用和配置参数('text')传递给嵌入脚本
jwplayer('id-of-container').setup({
file: '/path/to/my/video.mp4',
plugins: {
'/path/to/overlay.js': {
text: 'Text that you want to go within the overlayed banner'
}
}
});
结束===============================
====overlay.js 文件内容==============
(function( jwplayer ) {
var overlay = function( player, config, div ) {
var setupOverlay = function() {
div.innerHTML = config.text;
};
var showOverlay = function() {
setStyle({
opacity: 1
});
};
var hideOverlay = function() {
setStyle({
opacity: 0
});
};
var setStyle = function( object ) {
for(var style in object) {
div.style[ style ] = object[ style ];
}
};
// Matches our text container to the size of the player instance
this.resize = function( width, height ) {
setStyle({
position: 'absolute',
margin: '0',
padding: '10px 15px 10px',
background: 'rgba( 0, 0, 0, .7 )',
color: 'white',
fontSize: '12px',
width: '100%'
});
};
// Bind player events
player.onReady( setupOverlay );
player.onPlay( hideOverlay );
player.onPause( showOverlay );
player.onComplete( showOverlay );
};
jwplayer().registerPlugin( 'overlay', overlay );
})( jwplayer );
这提供了 JWPlayer 所需的完整 Javascript 堆栈。 JWPlayer 是免费的,带有水印。