Skip to content

Commit

Permalink
fix: use audio offset for id3 with audio-only (#1386)
Browse files Browse the repository at this point in the history
Co-authored-by: Pat O'Neill <[email protected]>
  • Loading branch information
mister-ben and misteroneill authored Apr 4, 2023
1 parent b4f44e4 commit e6d8b08
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/playlist-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2012,8 +2012,8 @@ export class PlaylistController extends videojs.EventTarget {
}

addMetadataToTextTrack(dispatchType, metadataArray, videoDuration) {
const timestampOffset = this.sourceUpdater_.videoTimestampOffset() === null ?
this.sourceUpdater_.audioTimestampOffset() : this.sourceUpdater_.videoTimestampOffset();
const timestampOffset = this.sourceUpdater_.videoBuffer ?
this.sourceUpdater_.videoTimestampOffset() : this.sourceUpdater_.audioTimestampOffset();

// There's potentially an issue where we could double add metadata if there's a muxed
// audio/video source with a metadata track, and an alt audio with a metadata track.
Expand Down
5 changes: 5 additions & 0 deletions test/segment-loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2494,6 +2494,9 @@ QUnit.module('SegmentLoader', function(hooks) {
// Simulate a caption event happening that will call handleCaptions_
const dispatchType = 0x10;

// Ensure no video buffer is present in the test case
loader.sourceUpdater_.videoBuffer = undefined;

loader.handleId3_(loader.pendingSegment_, metadata, dispatchType);
});

Expand All @@ -2511,6 +2514,8 @@ QUnit.module('SegmentLoader', function(hooks) {
const cue = addCueSpy.getCall(0).args[0];

assert.strictEqual(cue.value.data, 'This is a priv tag', 'included the text');

assert.strictEqual(cue.startTime, metadata[0].cueTime + loader.sourceUpdater_.audioTimestampOffset(), 'cue.startTime offset from audioTimestampOffset');
done();
});

Expand Down

0 comments on commit e6d8b08

Please sign in to comment.