palying_visit.jsp 7.08 KB
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!doctype html>
<html>
<head>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path ;
	String devicetype = (String) request.getAttribute("devicetype");
	if(devicetype == null)
		devicetype="android";
%>
<meta charset="utf-8">
<meta content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" name="viewport" />
<meta name='apple-itunes-app' content='app-id=1141232775'>
<title>蜜家直播</title>
<link rel="stylesheet" href="http://apps.bdimg.com/libs/bootstrap/3.3.0/css/bootstrap.min.css">
<link href="css/fbh.css" rel="stylesheet" type="text/css">
<link href="<%=basePath%>/css/video-js.min.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<%=basePath%>/js/jquery-1.9.1.min.js"></script>
<script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/emoji/emoji.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/jwplayer.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/jwpsrv.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/jwpsrv_frq.js"></script>
<script type="text/javascript">jwplayer.key="lsUqQ+PB1edH+bYoMb85Yr5CuPlXyhK/ngcyNQ==";</script>
</head>

<body>
<div class="container">
	<div class="top">
		<div class="playing-people">
			<!--img src="${user.avatar}" class="img-responsive" id="people" /-->
			
			<div id="playing-bottom">
				<img src="img/logo.png" width="45" height="45" class="pull-left" />
				<span class="top-title">蜜家直播</span>
				<div class="download pull-right">
					<a href="<%=basePath%>/assets/download.html">立即下载</a>
				</div>
			</div>
			<%
			if(devicetype.equals("pc")){
			%>
			<div  id='container'></div>
			<%}else{%>
			<div id="container">
			<video autoplay="false"  width="100%" height="100%" preload="auto" poster="${live.thumbnail}">
				<source type="video/mp4" src="${m3u8Addr}" />
			</video>
			</div>
			<%} %>
 				  
		</div>
		
		<div class="zhubomess">
			<div class="title">
				<img src="${user.avatar}" width="50" height="50" />
				<div class="message">
					<div>
						<span class="name pull-left" id="username">${user.emoName}</span>
						<img src="img/${user.sex == 'female'?user.sex:'male'}.png" class="icon pull-left" />
						<span class="glyphicon glyphicon-star-empty pull-left"><span style="padding-left: 3px;">${user.level}</span></span>
						<div class="clear"></div>
					</div>
					<div class="mijia">蜜家号:${user.id}</div>
				</div>
				<a href="#" class="follow">+关注</a>
				<div class="clear"></div>
			</div>	
		</div>
		<div class="guankan">观看直播  &nbsp;${live.audienceTotalNum}人</div>
		
	</div>	
</div>
<script>
	$(document).ready(function() {
		var imgHeight = $("#people").height();
		var docHeight=$(document.body).height();
		//console.log(docHeight);
		//console.log(imgHeight);
		if(imgHeight<=0)
			imgHeight=460;
		$("#people").css("height",imgHeight);
		$("#container_wrapper").css("top",50);
		$("#container").css("height",imgHeight);
		$("#container").css("width","100%");
		$("#playing-bottom").css("top",imgHeight+75);
		//$("#playing-bottom").css("top",docHeight-imgHeight-373);
	});
	
	//页面需要显示unicode编码的字符,可以后台或前端进行转换,数据库保存的是utf8mb4编码,读出来后,需要转换一次
	$('#username').emoji();
	
</script>
<script>
	//播放设置
	var player = null;
	
	function getWidth(){
		var wWidth= $("#people").width();
		if(wWidth<=0)
			wWidth="100%";
		$("#container_wrapper").css("width","100%");
		return wWidth;
	};
	
	function getHeight() {
		var wHeight = $("#people").height();
		if(wHeight<=0)
			wHeight=640;
		$("#container_wrapper").css("height",wHeight);
		$("#playing-bottom").css("top",wHeight+75);
		return wHeight;
	};

	function play() {
			player = jwplayer("container").setup({
				flashplayer: '<%=request.getContextPath()%>/js/jwplayer.flash.swf',
				id: 'playerID',
				width: getWidth(),
				height: getHeight(),
				file: '${live.videoAddr}',
				image: '${live.thumbnail}',
				primary: "flash",
				controls: true,
				type:"rtmp",
				events: {
					onComplete: onComplete,
					onReady: function () {
						$('#play-control').show();
						$('#media_status_msg').html('直播中,点击观看');
						set_pos();
					},
					onPlay: onPlay,
					onPause: onPause,
					onBuffer: onBuffer,
					onDisplayClick: onDisplayClick,
					onSetupError: onSetupError,
					onBufferChange: function () { console.log("onBufferChange!!!"); },
					onBufferFull: function () { console.log("onBufferFull!!!"); }
				},
				players:
				       [
				         { type: "html5"},
				         { type: "flash", src: '<%=request.getContextPath()%>/js/jwplayer.flash.swf' }
				       ]
			});
	}
	
	function onComplete() {
		//alert('播放完毕');
	}
	function onBuffer() {
		$('#media_status_msg').hide();
		$('#play-control').show();
		$('#play-control').attr('class', 'btn loading pa');
		console.log('onBuffer');
	}
	function onPlay() {
		$('#media_status_msg').hide();
		$('#play-control').hide();
		$('#play-control').attr('class', 'btn play pa');
	}
	function onPause() {
		$('#media_status_msg').hide();
		$('#play-control').show();
		$('#play-control').attr('class', 'btn play pa');
		playing = false;
		console.log('onPause');
	}
	function onDisplayClick() {
		player.pause();
	}
	function onSetupError(a, b) {
		
	}
	function user_show() {
		if (trim($('#nick').html()) == '') {
			$('.user').hide();
		}else{
			$('.user').show();
		}
	}
	function set_pos() {
		var play_left = $('#container_wrapper').offset().left;
	}
	function resize() {
		set_pos();
	}
	var playing = false;

	$(document).ready(function(){
		<%
		if(devicetype.equals("pc")){
		%>
			play();
			$('#play-control').click(function() {
				player.play();
				$('#play-control').show();
			});
		<%} %>
	});
</script>
<script type="text/javascript">     
            // To avoid the "protocol not supported" alert, fail must open another app.    
            var appstore = "https://itunes.apple.com/cn/app/facebook/id284882215?mt=8"    
            function applink(fail){    
                return function(){    
                    var clickedAt = +new Date;    
                    // During tests on 3g/3gs this timeout fires immediately if less than 500ms.    
                    setTimeout(function(){    
                              // To avoid failing on return to MobileSafari, ensure freshness!    
                              if (+new Date - clickedAt < 2000){    
                              window.location = fail;    
                              }    
                              }, 500);        
                };    
            }    
            document.getElementById("applink1").onclick = applink(appstore);    
            document.getElementById("applink2").onclick = applink(appstore);    
</script>     
</body>
</html>