diff --git a/src/session.ts b/src/session.ts index cac0412..3cf4614 100644 --- a/src/session.ts +++ b/src/session.ts @@ -161,7 +161,7 @@ export class MediaSession { ): MediaEvent { // Set event option based on options or current state this.currentPlayheadPosition = - options?.currentPlayheadPosition || this.currentPlayheadPosition; + options?.currentPlayheadPosition ?? this.currentPlayheadPosition; // Merge Session Attributes with any other optional Event Attributes. // Event-Level Custom Attributes will override Session Custom Attributes if there is a collison. diff --git a/test/session.test.ts b/test/session.test.ts index 06fd7d9..721cec4 100644 --- a/test/session.test.ts +++ b/test/session.test.ts @@ -746,6 +746,24 @@ describe('MediaSession', () => { ); expect(bond.args[0][0].options.currentPlayheadPosition).to.eq(32); }); + + it('accepts currentPlayheadPosition with a value of 0', () => { + const bond = sinon.spy(mp, 'logBaseEvent'); + + const options = { + currentPlayheadPosition: 0, + customAttributes: { + content_rating: 'epic', + }, + }; + + mpMedia.logMediaSessionStart(options); + + expect(bond.args[0][0].options.customAttributes).to.eqls( + options.customAttributes, + ); + expect(bond.args[0][0].options.currentPlayheadPosition).to.eq(0); + }); }); describe('#logMediaSessionEnd', () => {