JavaScript jwplayer没有玩

时间:2017-12-13 16:17:46

标签: javascript jquery jwplayer

我使用jwplayer构建了一个脚本,在我的浏览器中播放rtmp流,但不知何故,如果我点击播放没有任何反应。

我在播放机上方收到此消息:错误loaidng播放器:找到了noplayable来源。

在我的html中,我有一个像这样的Basic div:

<div id="player"></div>

到目前为止我的脚本:

var data = [];
var jw_width = 1900,
    jw_height = 1080;

// Outputs some logs about jwplayer
function print(t, obj) {
    for (var a in obj) {
        if (_typeof(obj[a]) === "object") {
            print(t + '.' + a, obj[a]);
        } else {
            data[t + '.' + a] = obj[a];
        }
    }
}

$(document).ready(function () {

    jwplayer('player').setup({
        wmode: 'transparent',
        width: jw_width,
        height: jw_height,
        stretching: 'exactfit'
    });

    $('#restart-stream').click(function () {
        jwplayer('player').stop();
        startPlayer("rtmp://31.151.24.38:1935/app/stream");
    });

    $('#stop-stream').click(function () {
        jwplayer('player').stop();
    });
});

// Starts the flash player
function startPlayer(stream) {
    jwplayer('player').setup({
        height: jw_height,
        width: jw_width,
        stretching: 'exactfit',
        sources: [{
            file: stream
        }],
        rtmp: {
            bufferlength: 1
        }
    });
    jwplayer("player").onMeta(function (event) {
        var info = "";
        for (var key in data) {
            info += key + " = " + data[key] + "<BR>";
        }
        print("event", event);
    });
    jwplayer('player').play();
}

0 个答案:

没有答案