@waveform-playlist/playout 10.4.0 → 11.0.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/index.mjs CHANGED
@@ -183,11 +183,17 @@ var ToneTrack = class {
183
183
  const transport = getTransport();
184
184
  try {
185
185
  transport.clear(scheduled.scheduleId);
186
- } catch {
186
+ } catch (err) {
187
+ console.warn(
188
+ '[waveform-playlist] removeScheduledClip: clear failed on track "' + this.id + '": ' + String(err)
189
+ );
187
190
  }
188
191
  try {
189
192
  scheduled.fadeGainNode.disconnect();
190
- } catch {
193
+ } catch (err) {
194
+ console.warn(
195
+ '[waveform-playlist] removeScheduledClip: disconnect failed on track "' + this.id + '": ' + String(err)
196
+ );
191
197
  }
192
198
  this.scheduledClips.splice(index, 1);
193
199
  }
@@ -199,6 +205,7 @@ var ToneTrack = class {
199
205
  * needing to explicitly stop it.
200
206
  */
201
207
  replaceClips(newClips, newStartTime) {
208
+ const startTimeChanged = newStartTime !== void 0 && newStartTime !== this.track.startTime;
202
209
  if (newStartTime !== void 0) {
203
210
  this.track.startTime = newStartTime;
204
211
  }
@@ -206,15 +213,19 @@ var ToneTrack = class {
206
213
  const kept = [];
207
214
  const toAdd = [];
208
215
  const matched = /* @__PURE__ */ new Set();
209
- for (const clipInfo of newClips) {
210
- const idx = this.scheduledClips.findIndex(
211
- (s, i) => !matched.has(i) && this._clipsEqual(s.clipInfo, clipInfo)
212
- );
213
- if (idx !== -1) {
214
- kept.push(this.scheduledClips[idx]);
215
- matched.add(idx);
216
- } else {
217
- toAdd.push(clipInfo);
216
+ if (startTimeChanged) {
217
+ toAdd.push(...newClips);
218
+ } else {
219
+ for (const clipInfo of newClips) {
220
+ const idx = this.scheduledClips.findIndex(
221
+ (s, i) => !matched.has(i) && this._clipsEqual(s.clipInfo, clipInfo)
222
+ );
223
+ if (idx !== -1) {
224
+ kept.push(this.scheduledClips[idx]);
225
+ matched.add(idx);
226
+ } else {
227
+ toAdd.push(clipInfo);
228
+ }
218
229
  }
219
230
  }
220
231
  for (let i = 0; i < this.scheduledClips.length; i++) {
@@ -222,11 +233,17 @@ var ToneTrack = class {
222
233
  const scheduled = this.scheduledClips[i];
223
234
  try {
224
235
  tp.clear(scheduled.scheduleId);
225
- } catch {
236
+ } catch (err) {
237
+ console.warn(
238
+ '[waveform-playlist] replaceClips: clear failed on track "' + this.id + '": ' + String(err)
239
+ );
226
240
  }
227
241
  try {
228
242
  scheduled.fadeGainNode.disconnect();
229
- } catch {
243
+ } catch (err) {
244
+ console.warn(
245
+ '[waveform-playlist] replaceClips: disconnect failed on track "' + this.id + '": ' + String(err)
246
+ );
230
247
  }
231
248
  }
232
249
  }