-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
139 lines (136 loc) · 4.39 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>长胖小电视</title>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<script src="index.browser.min.js"></script>
<script src="hlsjs-p2p-engine.min.js"></script>
<script src="p2p-chimee-kernel-hls@latest"></script>
<style>
body,html{width:100%;height:100%;background:#000;padding:0;margin:0;overflow-x:hidden;overflow-y:hidden}
.videotop {width:100%;padding-bottom: 15px;background:#1D1D1D;position:relative;z-index:1000;}
#player{width:100%;text-align:center;}
@media screen and (max-width:1020px){
.videotop{height:150px;}
#player{height:calc(100% - 165px);}
}
@media screen and (min-width:1020px){
.videotop{height:50px;}
#player{height:calc(100% - 65px);}
}
#tip {
position: fixed;
color: gray;
font-size: 30px;
top: 350px;
left: 0px;
right: 0px;
}
.top-item{
float: left;
margin-left: 30px;
margin-top: 15px;
}
#logo {
width: 125px;
color: white;
font-size: 23px;
font-weight: bold;
display: inline-block;
height: 33px;
line-height: 33px;
}
.op-input {
width: 250px;
float: left;
border:0;
outline: none;
height: 33px;
padding: 0 10px;
}
.op-button {
cursor: pointer;
padding: 0 15px;
float: left;
border:0;
outline: none;
height: 33px;
font-weight: bold;
}
</style>
</head>
<body>
<div class="videotop">
<div class="top-item"><span id="logo">长胖小电视</span></div>
<div class="top-item"><input class="op-input" id="bf" placeholder="请输入视频资源链接(mp4/m3u8/avi...)" value='<?php echo $_GET['bf'];?>' /><button class="op-button" onclick="bf()">播放</button></div>
<div style="clear:both;"></div>
</div>
<div id="player">
<span id="tip">
<?php if(isset($_GET['bf'])){
echo "视频加载中....";
} else{
echo "欢迎使用长胖小电视!";
} ?>
</span>
</div>
<script>
function tip(display,content){
var tip = document.getElementById("tip");
if(display){
tip.style.cssText = "z-index: 999;"
}else{
tip.style.cssText = "z-index: -1;"
}
tip.innerHTML = content;
}
function play(src){
if((src.indexOf(".mp4?") > -1 || src.lastIndexOf(".mp4") == src.length - 4) || (src.indexOf(".m3u8?") > -1 || src.lastIndexOf(".m3u8") == src.length - 5) || (src.indexOf(".avi?") > -1 || src.lastIndexOf(".avi") == src.length - 4)){
var player = new Chimee({
wrapper: '#player',
src: src,
controls: true,
autoplay: true,
preload: true,
kernels: {
hls: {
handler: window.ChimeeKernelHls,
maxBufferSize: 0,
maxBufferLength: 5,
liveSyncDuration: 30,
p2pConfig: {
logLevel: 'debug',
live: false,
}
}
},
});
focusVideo();
}else{
var iframe = document.createElement('iframe');
iframe.src=src;
iframe.style.cssText="height:100%;width:100%;border:none;float:left;"
document.getElementById("player").appendChild(iframe);
}
}
function focusVideo(){
var video = document.getElementsByTagName("video")[0];
if(video){
video.focus();
}else{
setTimeout("focusVideo();",500);
}
}
function bf(){
document.getElementById("tip").innerText = "视频加载中....";
window.location = "/?bf=" + document.getElementById("bf").value;
}
<?php
//如果是点击的播放按钮,则直接播放对应资源
if(isset($_GET['bf'])){ ?>
play("<?php echo $_GET['bf'];?>");
<?php }?>
</script>
</body>
</html>