videojs / videojs-contrib-ads

A Tool for Building Video.js Ad Plugins
http://videojs.github.io/videojs-contrib-ads/
Other
384 stars 257 forks source link

internal state reset when replaying the video #273

Closed narirou closed 7 years ago

narirou commented 7 years ago

Hello.

We have a problem that the events when replaying the video are sometimes different.

This plugin has a function to re-dispatch event while AD is playing. In the code, the ended event determines whether it becomes contenteded or ended depending on the state of _contentHasEnded. https://github.com/videojs/videojs-contrib-ads/blob/master/src/plugin.js#L681

When replaying the video, since _contentHasEnded is not reset, I think that the ended event will not fire.

Is there a way to reset all the internal state of AD (including _contentHasEnded) and fire the ended event again?

Thanks.

incompl commented 7 years ago

If the _contentHasEnded state is set, there is still an ended event after replaying the video. This is the code that handles it:

https://github.com/videojs/videojs-contrib-ads/blob/master/src/plugin.js#L540-L548

Think of _contentHasEnded as meaning "the content has ended at least once, but could end again"