@clockworkdog/cogs-client 2.10.1 → 2.11.0
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/README.md +4 -4
- package/dist/AudioPlayer.js +5 -3
- package/dist/CogsConnection.js +23 -3
- package/dist/browser/index.mjs +1716 -0
- package/dist/browser/index.umd.js +19 -0
- package/dist/index.d.ts +5 -7
- package/dist/index.js +3 -9
- package/dist/types/CogsPluginManifest.d.ts +1 -1
- package/package.json +12 -7
- package/dist/RtspStreamer.d.ts +0 -27
- package/dist/RtspStreamer.js +0 -101
- package/dist/browser/index.js +0 -7565
- /package/dist/{helpers → utils}/urls.d.ts +0 -0
- /package/dist/{helpers → utils}/urls.js +0 -0
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ We'll make an annoying bell that rings every second.
|
|
|
19
19
|
"events": {
|
|
20
20
|
"toCogs": [
|
|
21
21
|
{
|
|
22
|
-
"name": "
|
|
22
|
+
"name": "ping"
|
|
23
23
|
}
|
|
24
24
|
]
|
|
25
25
|
}
|
|
@@ -46,7 +46,7 @@ We'll make an annoying bell that rings every second.
|
|
|
46
46
|
const cogsConnection = new CogsConnection(manifest);
|
|
47
47
|
cogsConnection.addEventListener('open', () => {
|
|
48
48
|
interval = setInterval(() => {
|
|
49
|
-
cogsConnection.sendEvent('
|
|
49
|
+
cogsConnection.sendEvent('ping')
|
|
50
50
|
}, 1000);
|
|
51
51
|
});
|
|
52
52
|
cogsConnection.addEventListener('close', () => {
|
|
@@ -61,10 +61,10 @@ We'll make an annoying bell that rings every second.
|
|
|
61
61
|
1. Enable your plugin in COGS.
|
|
62
62
|
|
|
63
63
|
<img src="./assets/quickstart-enable-plugin.png" alt="Enabling COGS plugin" width="600">
|
|
64
|
-
1. Create a behaviour to listen to the `
|
|
64
|
+
1. Create a behaviour to listen to the `ping` event.
|
|
65
65
|
|
|
66
66
|
<img src="./assets/quickstart-behavior-when.png" alt="Adding a behaviour" width="600">
|
|
67
|
-
1. Make the behaviour do something.
|
|
67
|
+
1. Make the behaviour do something. In this case it'll play our bell sound.
|
|
68
68
|
|
|
69
69
|
<img src="./assets/quickstart-behavior-do.png" alt="Adding a behaviour" width="600">
|
|
70
70
|
1. Start the show!
|
package/dist/AudioPlayer.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
|
4
|
+
/// <reference path="./types/howler.d.ts" />
|
|
5
|
+
const howler_core_min_js_1 = require("howler/dist/howler.core.min.js");
|
|
4
6
|
const DEBUG = false;
|
|
5
7
|
// Check an iOS-only property (See https://developer.mozilla.org/en-US/docs/Web/API/Navigator#non-standard_properties)
|
|
6
8
|
const IS_IOS = typeof navigator.standalone !== 'undefined';
|
|
@@ -77,7 +79,7 @@ class AudioPlayer {
|
|
|
77
79
|
}
|
|
78
80
|
setGlobalVolume(volume) {
|
|
79
81
|
this.globalVolume = volume;
|
|
80
|
-
|
|
82
|
+
howler_core_min_js_1.Howler.volume(volume);
|
|
81
83
|
this.notifyStateListeners();
|
|
82
84
|
}
|
|
83
85
|
playAudioClip(path, { playId, volume, fade, loop }) {
|
|
@@ -407,7 +409,7 @@ class AudioPlayer {
|
|
|
407
409
|
this.eventTarget.dispatchEvent(new CustomEvent(type, { detail }));
|
|
408
410
|
}
|
|
409
411
|
createPlayer(path, config) {
|
|
410
|
-
const player = new
|
|
412
|
+
const player = new howler_core_min_js_1.Howl({
|
|
411
413
|
src: this.cogsConnection.getAssetUrl(path),
|
|
412
414
|
autoplay: false,
|
|
413
415
|
loop: false,
|
package/dist/CogsConnection.js
CHANGED
|
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.CogsShowPhaseChangedEvent = exports.CogsMediaConfigChangedEvent = exports.CogsIncomingEvent = exports.CogsStateChangedEvent = exports.CogsConfigChangedEvent = exports.CogsMessageEvent = exports.CogsConnectionCloseEvent = exports.CogsConnectionOpenEvent = void 0;
|
|
7
7
|
const ShowPhase_1 = __importDefault(require("./types/ShowPhase"));
|
|
8
8
|
const reconnecting_websocket_1 = __importDefault(require("reconnecting-websocket"));
|
|
9
|
-
const urls_1 = require("./
|
|
9
|
+
const urls_1 = require("./utils/urls");
|
|
10
10
|
const DataStore_1 = __importDefault(require("./DataStore"));
|
|
11
|
+
const timesync_1 = require("@clockworkdog/timesync");
|
|
11
12
|
class CogsConnection {
|
|
12
13
|
get config() {
|
|
13
14
|
return { ...this.currentConfig };
|
|
@@ -68,10 +69,29 @@ class CogsConnection {
|
|
|
68
69
|
this.dispatchEvent(new CogsConnectionOpenEvent());
|
|
69
70
|
this.setState(this.currentState); // TODO: Remove this because you should set it manually...??
|
|
70
71
|
};
|
|
72
|
+
const timeSyncClient = (0, timesync_1.createTimeSyncClient)({
|
|
73
|
+
interval: 60000,
|
|
74
|
+
send: (data) => {
|
|
75
|
+
this.websocket.send(JSON.stringify(data));
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
this.websocket.addEventListener('message', ({ data }) => {
|
|
79
|
+
try {
|
|
80
|
+
const response = JSON.parse(data);
|
|
81
|
+
if (typeof response === 'object' && response !== null && 'timesync' in response) {
|
|
82
|
+
const parsed = response;
|
|
83
|
+
timeSyncClient.receive(parsed);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
console.error(e);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
71
90
|
this.websocket.onclose = () => {
|
|
91
|
+
timeSyncClient.destroy();
|
|
72
92
|
this.dispatchEvent(new CogsConnectionCloseEvent());
|
|
73
93
|
};
|
|
74
|
-
this.websocket.
|
|
94
|
+
this.websocket.addEventListener('message', ({ data }) => {
|
|
75
95
|
try {
|
|
76
96
|
const parsed = JSON.parse(data);
|
|
77
97
|
try {
|
|
@@ -127,7 +147,7 @@ class CogsConnection {
|
|
|
127
147
|
catch (e) {
|
|
128
148
|
console.error('Unable to parse incoming data from server', data, e);
|
|
129
149
|
}
|
|
130
|
-
};
|
|
150
|
+
});
|
|
131
151
|
// Tell COGS when any data store items change
|
|
132
152
|
this.store.addEventListener('items', (event) => {
|
|
133
153
|
this.sendDataStoreItems(event.items);
|