使用tvp.player_v2_zepto.js播放腾讯视频

作者: JONE 分类: PHPer 发布时间: 2020-04-05 09:36

目前测试发现,仅能在移动端播放视频且无广告,此播放器插件根据浏览器的User-Agent来判断客户端类型。

tvp.player_v2_zepto.js还需要zepto.min.js。

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
		<script src="https://cdn.bootcss.com/zepto/1.2.0/zepto.min.js"></script>
		<script src="https://imgcache.qq.com/tencentvideo_v1/tvp/js/tvp.player_v2_zepto.js" charset="utf-8"></script>
		<title></title>
	</head>
	<body>
		<div class="rich_media_content" id="js_content">
			
		</div>
		
	<script type="text/javascript">
		//var vid = 't0508alameb';
		var vid = 'l094569sefd';
		function play_video () {
			var video , player, playStatus = 'pending';
			
			var elId = 'mod_player_skin_0';
			$("#js_content").html('<div id="' + elId + '" class="player_skin" style="padding-top:6px;"></div>');
			var elWidth = $("#js_content").width();
			playVideo(vid, elId, elWidth);
		}
		function playVideo(vid, elId, elWidth) {
				video = new tvp.VideoInfo();
				video.setVid(vid);
				player = new tvp.Player(elWidth, 200);
				player.setCurVideo(video);
				player.addParam("wmode", "transparent");
				player.addParam("pic", tvp.common.getVideoSnapMobile(vid));
				player.write(elId);
			}
	
	    play_video();
	</script>	
	</body>
</html>