YTPlayer.js一个开源jQuery组件,可轻松构建您的自定义Youtube播放器或使用Youtube视频作为页面的背景。
![]() |
---|
(下载的附件中附有DEMO)
注意事项:
1)该插件只有在web服务器下使用时才能工作。如果你将HTML页面作为文件运行(file://…),它就不起作用。如果你想在计算机上本地运行它,你需要安装一个web服务器(例如:MAMP for Mac,XAMP for Windows,LAMP for linux),然后从http://localhost…或您在Host文件中映射为localhost的任何内容。
2)该插件不适用于jquery.slim.js,因为它需要从精简版jquery中删除的方法。
<link href="css/jquery.mb.YTPlayer.min.css" media="all" rel="stylesheet" type="text/css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<script src="inc/jquery.mb.YTPlayer.js"></script>
<div id="bgndVideo" class="player" data-property="{videoURL:'http://youtu.be/BsekcY04xvQ',containment:'body',autoPlay:true, mute:true, startAt:0, opacity:1}">My video</div>
jQuery(function(){
jQuery("#[playerID]").YTPlayer();
});
官方文档(英文):https://github.com/pupunzi/jquery.mb.YTPlayer/wiki
GitHub 地址:https://github.com/pupunzi/jquery.mb.YTPlayer/wiki