radiantmediaplayer / rmp-vast

A client-side JavaScript solution to load, parse and display VAST 2, 3 & 4 resources with HTML5 video
https://www.radiantmediaplayer.com/rmp-vast/app/
Other
95 stars 37 forks source link

Units in VPAID.getAdRemainingTime(), VAST_PLAYER.getCurrentTime(), VAST_PLAYER.getDuration() #49

Closed kamtungc closed 2 years ago

kamtungc commented 2 years ago

In v.6.0.0 index.js, getAdRemainingTime() { if (this.adOnStage && this.creative && this.creative.isLinear) { if (this.isVPAID) { return VPAID.getAdRemainingTime.call(this); } else { const currentTime = VAST_PLAYER.getCurrentTime.call(this); const duration = VAST_PLAYER.getDuration.call(this); if (currentTime === -1 || duration === -1 || currentTime > duration) { return -1; } return (duration - currentTime) * 1000; } } return -1; }

In v.7.0.0 index.js, getAdRemainingTime() { if (this.adOnStage && this.creative && this.creative.isLinear) { if (this.isVPAID) { return VPAID.getAdRemainingTime.call(this) * 1000; } else { const currentTime = VAST_PLAYER.getCurrentTime.call(this); const duration = VAST_PLAYER.getDuration.call(this); if (currentTime === -1 || duration === -1 || currentTime > duration) { return -1; } return duration - currentTime; } } return -1; }

What is correct unit in VPAID.getAdRemainingTime(), VAST_PLAYER.getCurrentTime(), VAST_PLAYER.getDuration()? seconds? milliseconds?

According to readme.md, getAdCurrentTime() should return milliseconds. Then, v7.0.0 should correct getAdRemainingTime().

getAdCurrentTime(): return Number in ms, representing the current timestamp in the selected linear creative. -1 is returned if this value is not available.

How about this.isVPAID is FALSE, what is the correct value of duration - currentTime?

radiantmediaplayer commented 2 years ago

This is fixed in 7.1.0 - note that technically we are not obligated to provide these values for VPAID creatives as the AdRemainingTimeChange VPAID callback has been deprecated in VPAID 2.0. All timed values from getAdDuration, getAdCurrentTime, getAdRemainingTime are in milliseconds.