player.page.js
2.86 KB
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
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// to query the swf anti cache.
function player_get_version_code() { return "1.03"; }
function player_get_player_modal() { return 780; }
function player_get_player_width() { return player_get_player_modal() - 30; }
function player_get_player_height() { return player_get_player_width() * 9 / 19; }
/**
@param server the ip of server. default to window.location.hostname
@param vhost the vhost of rtmp. default to window.location.hostname
@param port the port of rtmp. default to 1935
@param app the app of rtmp. default to live.
@param stream the stream of rtmp. default to livestream.
*/
function build_default_rtmp_url() {
var query = parse_query_string();
var server = (query.server == undefined)? window.location.hostname:query.server;
var port = (query.port == undefined)? 1935:query.port;
var vhost = (query.vhost == undefined)? window.location.hostname:query.vhost;
var app = (query.app == undefined)? "qhwljia":query.app;
var stream = (query.stream == undefined)? "36020025198":query.stream;
return "rtmp://" + server + ":" + port + "/" + app + "/" + stream;
}
/**
@param server the ip of server. default to window.location.hostname
@param vhost the vhost of hls. default to window.location.hostname
@param hls_vhost the vhost of hls. override the server if specified.
@param hls_port the port of hls. default to window.location.port
@param app the app of hls. default to live.
@param stream the stream of hls. default to livestream.
*/
function build_default_hls_url() {
var query = parse_query_string();
// for http, use hls_vhost to override server if specified.
var server = window.location.hostname;
if (query.server != undefined) {
server = query.server;
} else if (query.hls_vhost != undefined) {
server = query.hls_vhost;
}
var port = (query.hls_port == undefined)? window.location.port:query.hls_port;
var app = (query.app == undefined)? "qhwlhls":query.app;
var stream = (query.stream == undefined)? "36020025198":query.stream;
if (port == "" || port == null || port == undefined) {
port = 80;
}
return "http://" + server + ":" + port + "/" + app + "/" + stream + "/index.m3u8";
}
/**
* initialize the page.
* @param rtmp_url the div id contains the rtmp stream url to play
* @param hls_url the div id contains the hls stream url to play
* @param modal_player the div id contains the modal player
*/
function player_init(modal_player) {
if (modal_player) {
$(modal_player).width(player_get_player_modal() + "px");
$(modal_player).css("margin-left", "-" + player_get_player_modal() / 2 +"px");
}
}