微信掃碼登錄 ×
基于video彈窗視頻播放代碼

基于video彈窗視頻播放代碼

收藏
基于video彈窗視頻播放代碼
使用jQuery video在線視頻播放功能。div圖片列表鼠標(biāo)懸停顯示視頻播放按鈕,點(diǎn)擊彈窗方式打開mp4視頻播放效果代碼。默認(rèn)我們需要配置ipath的視頻路徑。這是一款簡潔好用的彈窗視頻播放。

使用方法:

1、head引入css文件

<style type="text/css">
body{background-color: #222}
.videolist { position:relative; float:left; width:500px; height:300px; margin-right:50px; margin-top:15px; margin-bottom:30px; }
.videolist:hover{ cursor: pointer; }
.videoed { display:none; width:50px; height:50px; position: absolute; left:45%; top:45%; z-index:99; border-radius:100%; }
.videos{ display:none; border: 1px solid #080808; position:fixed; left:50%; top:50%; margin-left:-320px; margin-top:-210px; z-index:100; width:640px; height:360px; }
.vclose { position:absolute;right:1%; top:1%; border-radius:100%; cursor: pointer; }
</style>

2、head引入js文件

<script type="text/javascript" src="js/jquery.min.js"></script>

3、body引入HTML代碼

<div class="video">
	<div class="container" style="margin-top: 100px">
		<div class="videolist" vpath="v1.jpg" ipath="https://blz-videos.nosdn.127.net/1/OverWatch/OVR-S03_E03_McCree_REUNION_zhCN_1080P_mb78.mp4">
			<div class="vtit">視頻一</div>
			<img src="img/v1.jpg" width="540px" height="300px" />
			<div class="vtime">2018-06-22</div>
			<img src="img/play.png" class="videoed"/>
		</div>
		<div class="videolist" vpath="v2.jpg" ipath="https://blz-videos.nosdn.127.net/1/OverWatch/AnimatedShots/Overwatch_AnimatedShot_CinematicTrailer.mp4">
			<div class="vtit">視頻一</div>
			<img src="img/v2.jpg" width="540px" height="300px" />
			<div class="vtime">2018-06-22</div>
			<img src="img/play.png" class="videoed"/>
		</div>
		
		<div class="videos"></div>
	</div>
</div>

<script type="text/javascript">
$('.videolist').each(function(){ //遍歷視頻列表
	$(this).hover(function(){ //鼠標(biāo)移上來后顯示播放按鈕
		$(this).find('.videoed').show();
	},function(){
		$(this).find('.videoed').hide();
	});
	$(this).click(function(){ //這個(gè)視頻被點(diǎn)擊后執(zhí)行
		var img = $(this).attr('vpath');//獲取視頻預(yù)覽圖
		var video = $(this).attr('ipath');//獲取視頻路徑
		$('.videos').html("<video id=\"video\" poster='"+img+"' style='width: 640px' src='"+video+"' preload=\"auto\" controls=\"controls\" autoplay=\"autoplay\"></video><img onClick=\"close1()\" class=\"vclose\" src=\"img/gb.png\" width=\"25\" height=\"25\"/>");
		$('.videos').show();
	});
});

function close1(){
	var v = document.getElementById('video');//獲取視頻節(jié)點(diǎn)
	$('.videos').hide();//點(diǎn)擊關(guān)閉按鈕關(guān)閉暫停視頻
	v.pause();
	$('.videos').html();
}
</script>

使用聲明

1. 本站所有素材(未指定商用),僅限學(xué)習(xí)交流。
2. 會員在本站下載的原創(chuàng)商用和VIP素材后,只擁有使用權(quán),著作權(quán)歸原作者及17素材網(wǎng)所有。
3. 原創(chuàng)商用和VIP素材,未經(jīng)合法授權(quán),請勿用于商業(yè)用途,會員不得以任何形式發(fā)布、傳播、復(fù)制、轉(zhuǎn)售該素材,否則一律封號處理。
4. 本平臺織夢模板僅展示和個(gè)人非盈利用途,織夢系統(tǒng)商業(yè)用途請預(yù)先授權(quán)。

x
×
×

注冊

QQ注冊 立即下載 微信注冊 立即下載

簽到成功!

已連續(xù)簽到1天,連續(xù)簽到3天可獲得50積分

知道了