Skip to content

Commit 0d5e157

Browse files
committed
fix(job-worker): queue a PartInstanceTimingEvent on deactivation
1 parent 5854695 commit 0d5e157

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

packages/job-worker/src/playout/model/PlayoutPartInstanceModel.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ export interface PlayoutPartInstanceModel {
176176
* @param time Reported stopped time
177177
*/
178178
setReportedStoppedPlayback(time: Time): boolean
179+
/**
180+
* Set the Reported stopped playback time, including still-playing PieceInstances
181+
* @param time Reported stopped time on all available objects
182+
*/
183+
setReportedStoppedPlaybackWithPieceInstances(time: Time): boolean
179184

180185
/**
181186
* Set the rank of this PartInstance, to update it's position in the Segment

packages/job-worker/src/playout/model/implementation/PlayoutModelImpl.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,11 @@ export class PlayoutModelImpl extends PlayoutModelReadonlyImpl implements Playou
432432
deactivatePlaylist(): void {
433433
delete this.playlistImpl.activationId
434434

435+
if (this.currentPartInstance) {
436+
this.currentPartInstance.setReportedStoppedPlaybackWithPieceInstances(getCurrentTime())
437+
this.queuePartInstanceTimingEvent(this.currentPartInstance.partInstance._id)
438+
}
439+
435440
this.clearSelectedPartInstances()
436441

437442
this.#playlistHasChanged = true

packages/job-worker/src/playout/model/implementation/PlayoutPartInstanceModelImpl.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,19 @@ export class PlayoutPartInstanceModelImpl implements PlayoutPartInstanceModel {
471471
}
472472
return false
473473
}
474+
setReportedStoppedPlaybackWithPieceInstances(time: number): boolean {
475+
if (!this.partInstance.timings?.reportedStartedPlayback) return false
476+
477+
let setOnAll = this.setReportedStoppedPlayback(time)
478+
479+
for (const model of this.pieceInstances) {
480+
if (model.pieceInstance.reportedStartedPlayback) {
481+
setOnAll &&= model.setReportedStoppedPlayback(time)
482+
}
483+
}
484+
485+
return setOnAll
486+
}
474487

475488
setRank(rank: number): void {
476489
this.#compareAndSetPartValue('_rank', rank)

0 commit comments

Comments
 (0)