Skip to content

Commit

Permalink
Merge pull request #179 from bitmovin/feature/fix-seeking-in-adimmunity
Browse files Browse the repository at this point in the history
Fix seeking in Ad Immunity
  • Loading branch information
dweinber authored Oct 3, 2024
2 parents c0ef5ad + d4becbc commit 4cf763c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed

- Yospace error on source load and session initialization not returned in `load` promise rejection as reason
- Seeking over ad breaks during ad immunity led to wrong seek end position
- Default policy not aware of ad immunity, sometimes leading to wrong decisions for `canSeekTo`

## [2.7.0] - 2024-09-27

Expand Down
2 changes: 1 addition & 1 deletion src/ts/BitmovinYospacePlayerPolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class DefaultBitmovinYospacePlayerPolicy implements BitmovinYospacePlayer
return adBreak.active && adBreak.scheduleTime > currentTime && adBreak.scheduleTime < seekTarget;
});

if (skippedAdBreaks.length > 0) {
if (skippedAdBreaks.length > 0 && !this.player.isAdImmunityActive()) {
const adBreakToPlay = skippedAdBreaks[skippedAdBreaks.length - 1];
return adBreakToPlay.scheduleTime;
}
Expand Down
9 changes: 7 additions & 2 deletions src/ts/InternalBitmovinYospacePlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ export class InternalBitmovinYospacePlayer implements BitmovinYospacePlayerAPI {

this.startAdImmunityPeriod();

if (this.cachedSeekTarget) {
if (this.cachedSeekTarget !== null) {
this.seek(this.cachedSeekTarget, 'yospace-ad-skipping');
this.cachedSeekTarget = null;
}
Expand Down Expand Up @@ -1223,7 +1223,12 @@ export class InternalBitmovinYospacePlayer implements BitmovinYospacePlayerAPI {
this.player.pause();
this.unpauseAfterSeek = true;

this.player.seek(seekTarget);
if (this.cachedSeekTarget !== null) {
this.player.seek(this.cachedSeekTarget, 'yospace-ad-skipping');
this.cachedSeekTarget = null;
} else {
this.seek(seekTarget);
}
}

private onTimeChanged = (event: TimeChangedEvent) => {
Expand Down
7 changes: 4 additions & 3 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -281,19 +281,20 @@
});
});

['moduleready', 'playing', 'metadata', 'metadataparsed'].forEach(function (eventName) {
['moduleready', 'playing', 'metadata', 'metadataparsed', 'adimmunitystarted', 'adimmunityended'].forEach(function (eventName) {
yospacePlayer.on(eventName, function (event) {
log(createLogFromEvent(event));
});
});

['error', 'yospaceerror', 'aderror'].forEach(function (eventName) {
['error', 'yospaceerror', 'policyerror', 'aderror'].forEach(function (eventName) {
yospacePlayer.on(eventName, function (event) {
console.error(createLogFromEvent(event));
});
});

yospacePlayer.setPolicy(simplePolicy);
// We are using the default, built-in policy in the demo. Another policy can easily be set using this method:
// yospacePlayer.setPolicy(simplePolicy);

yospacePlayer.on('segmentplayback', function (event) {
if (event.mimeType === 'video/mp4') {
Expand Down

0 comments on commit 4cf763c

Please sign in to comment.