forked from Streamedian/html5_rtsp_player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
48 lines (44 loc) · 1.5 KB
/
example.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.Debug);
getTagged("transport:ws").setLevel(LogLevel.Error);
getTagged("client:rtsp").setLevel(LogLevel.Debug);
getTagged("mse").setLevel(LogLevel.Debug);
let wsTransport = {
constructor: WebsocketTransport,
options: {
socket: "wss://specforge.com/ws/"
// socket: "ws://localhost:8080/ws/"
}
};
window.StreamedianPlayer = new streamedian.WSPlayer('test_video', {
// url: `${STREAM_UNIX}${STREAM_URL}`,
// type: wsp.StreamType.RTSP,
modules: [
{
client: RTSPClient,
transport: wsTransport
}
],
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) {
this.setCredentials.apply(this, c.split(':'));
resolve();
} else {
reject();
}
});
}
});
var setUrl = document.getElementById('set_new_url');
setUrl.onclick = function() {
StreamedianPlayer.setSource(document.getElementById('stream_url').value, streamedian.StreamType.RTSP);
};