@clockworkdog/cogs-client 1.3.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AudioPlayer.js +5 -0
- package/dist/CogsConnection.d.ts +6 -0
- package/dist/CogsConnection.js +10 -0
- package/dist/RtspStreamer.d.ts +21 -0
- package/dist/RtspStreamer.js +37 -0
- package/dist/browser/index.js +2443 -149
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/package.json +2 -1
package/dist/AudioPlayer.js
CHANGED
|
@@ -109,6 +109,11 @@ class AudioPlayer {
|
|
|
109
109
|
clipPlayer.player.off('fade', undefined, soundId);
|
|
110
110
|
clipPlayer.player.off('end', undefined, soundId);
|
|
111
111
|
clipPlayer.player.off('stop', undefined, soundId);
|
|
112
|
+
// Non-preloaded clips don't yet have an HTML audio node
|
|
113
|
+
// so we need to set the audio output when it's playing
|
|
114
|
+
clipPlayer.player.once('play', () => {
|
|
115
|
+
setPlayerSinkId(clipPlayer.player, this.sinkId);
|
|
116
|
+
});
|
|
112
117
|
clipPlayer.player.once('stop', () => this.handleStoppedClip(path, playId, soundId), soundId);
|
|
113
118
|
// Looping clips fire the 'end' callback on every loop
|
|
114
119
|
clipPlayer.player.on('end', () => {
|
package/dist/CogsConnection.d.ts
CHANGED
|
@@ -74,6 +74,12 @@ export default class CogsConnection<CustomTypes extends {
|
|
|
74
74
|
sendInitialMediaClipStates(allMediaClipStates: AllMediaClipStatesMessage): void;
|
|
75
75
|
sendMediaClipState(mediaClipState: MediaClipStateMessage): void;
|
|
76
76
|
sendAudioOutputs(audioOutputs: MediaDeviceInfo[]): void;
|
|
77
|
+
/**
|
|
78
|
+
* Show or hide the plugin window.
|
|
79
|
+
* @param visible Whether to show or hide the window
|
|
80
|
+
* This is only relevant for plugins, not for Media Master content.
|
|
81
|
+
*/
|
|
82
|
+
setPluginWindowVisible(visible: boolean): void;
|
|
77
83
|
addEventListener<EventName extends keyof ConnectionEventListeners<CustomTypes>, EventValue extends ConnectionEventListeners<CustomTypes>[EventName]>(type: EventName, listener: (ev: CustomEvent<EventValue>) => void, options?: boolean | AddEventListenerOptions): void;
|
|
78
84
|
removeEventListener<EventName extends keyof ConnectionEventListeners<CustomTypes>, EventValue extends ConnectionEventListeners<CustomTypes>[EventName]>(type: EventName, listener: (ev: CustomEvent<EventValue>) => void, options?: boolean | EventListenerOptions): void;
|
|
79
85
|
private dispatchEvent;
|
package/dist/CogsConnection.js
CHANGED
|
@@ -146,6 +146,16 @@ class CogsConnection {
|
|
|
146
146
|
this.websocket.send(JSON.stringify({ audioOutputs }));
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Show or hide the plugin window.
|
|
151
|
+
* @param visible Whether to show or hide the window
|
|
152
|
+
* This is only relevant for plugins, not for Media Master content.
|
|
153
|
+
*/
|
|
154
|
+
setPluginWindowVisible(visible) {
|
|
155
|
+
if (this.isConnected) {
|
|
156
|
+
this.websocket.send(JSON.stringify({ window: { visible } }));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
149
159
|
// Type-safe wrapper around EventTarget
|
|
150
160
|
addEventListener(type, listener, options) {
|
|
151
161
|
this.eventTarget.addEventListener(type, listener, options);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Html5VideoPipeline } from '@clockworkdog/media-stream-library-browser';
|
|
2
|
+
/**
|
|
3
|
+
* Manages a websocket connection to the COGS TCP relay which can be used to send RTSP video
|
|
4
|
+
* feeds to the web.
|
|
5
|
+
*/
|
|
6
|
+
export default class RtspStreamer {
|
|
7
|
+
private _websocketUri;
|
|
8
|
+
constructor({ hostname, port, path, }?: {
|
|
9
|
+
hostname?: string;
|
|
10
|
+
port?: number;
|
|
11
|
+
path?: string;
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Start an RTSP video stream on with the given URI on the given video element.
|
|
15
|
+
* @returns The playing HTML5 video pipeline.
|
|
16
|
+
*/
|
|
17
|
+
play(params: {
|
|
18
|
+
uri: string;
|
|
19
|
+
videoElement: HTMLVideoElement;
|
|
20
|
+
}): Html5VideoPipeline;
|
|
21
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const media_stream_library_browser_1 = require("@clockworkdog/media-stream-library-browser");
|
|
4
|
+
const urls_1 = require("./helpers/urls");
|
|
5
|
+
/**
|
|
6
|
+
* Manages a websocket connection to the COGS TCP relay which can be used to send RTSP video
|
|
7
|
+
* feeds to the web.
|
|
8
|
+
*/
|
|
9
|
+
class RtspStreamer {
|
|
10
|
+
constructor({ hostname = document.location.hostname, port = urls_1.COGS_SERVER_PORT, path = '/tcp-proxy', } = {}) {
|
|
11
|
+
this._websocketUri = `ws://${hostname}:${port}${path}`;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Start an RTSP video stream on with the given URI on the given video element.
|
|
15
|
+
* @returns The playing HTML5 video pipeline.
|
|
16
|
+
*/
|
|
17
|
+
play(params) {
|
|
18
|
+
const { uri, videoElement } = params;
|
|
19
|
+
const pipeline = new media_stream_library_browser_1.Html5VideoPipeline({
|
|
20
|
+
ws: { uri: this._websocketUri },
|
|
21
|
+
rtsp: { uri: uri },
|
|
22
|
+
mediaElement: videoElement,
|
|
23
|
+
});
|
|
24
|
+
// Restart stream on RTCP BYE (stream ended)
|
|
25
|
+
pipeline.rtsp.onRtcp = (rtcp) => {
|
|
26
|
+
if (media_stream_library_browser_1.isRtcpBye(rtcp)) {
|
|
27
|
+
setTimeout(() => this.play(params), 0);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
// Start playback when ready
|
|
31
|
+
pipeline.ready.then(() => {
|
|
32
|
+
pipeline.rtsp.play();
|
|
33
|
+
});
|
|
34
|
+
return pipeline;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.default = RtspStreamer;
|