player.page.js 2.86 KB
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////

// 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");
    }
}