-
Notifications
You must be signed in to change notification settings - Fork 598
/
streamedian.js
48 lines (44 loc) · 1.49 KB
/
streamedian.js
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
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);
}
};