加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
streamedian.js 1.49 KB
一键复制 编辑 原始数据 按行查看 历史
kreopt 提交于 2017-11-27 18:20 . * v0.3.10
import {LogLevel, getTagged, setDefaultLogLevel} from 'bp_logger';
import * as streamedian from 'streamedian/player.js';
import WebsocketTransport from 'streamedian/transport/websocket.js';
import RTSPClient from 'streamedian/client/rtsp/client.js';
import {isSafari} from "streamedian/core/util/browser.js";
setDefaultLogLevel(LogLevel.Error);
window.Streamedian = {
logger(tag) {
return getTagged(tag)
},
player(node, opts) {
if (!opts.socket) {
throw new Error("socket parameter is not set");
}
let _options = {
modules: [
{
client: RTSPClient,
transport: {
constructor: WebsocketTransport,
options: {
socket: opts.socket
}
}
}
],
errorHandler(e) {
alert(`Failed to start player: ${e.message}`);
},
queryCredentials(client) {
return new Promise((resolve, reject) => {
let c = prompt('input credentials in format user:password');
if (c) {
client.setCredentials.apply(client, c.split(':'));
resolve();
} else {
reject();
}
});
}
};
return new streamedian.WSPlayer(node, _options);
}
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化