MailOnline / videojs-vast-vpaid

video.js vast plugin
MIT License
296 stars 232 forks source link

HTML5 tech ads when 'original' video is Flash #179

Open alex-phillips opened 8 years ago

alex-phillips commented 8 years ago

There is an issue that occurs when the 'original' video content of the player uses the Flash tech but the preroll ad requires HTML5. It appears that much of the code the plugin performs (including its sanity checking on the tech, initializing the ad, etc) assumes that the currently active tech is the same tech that the preroll will use. This does work in many cases (i.e., the original video is an rtmp/mp4 stream and the preroll is a video/mp4 in which case both techs can play this type), but in the event the original video is a Flash format and the preroll is an HTML5 format (i.e., application/javascript), then these checks cause errors which prevent the preroll from playing properly.

The easiest way to fix this issue is to simply call player.reset() somewhere before this sanity check occurs and before any specific variables are set that related to the tech needed for the preroll (ex: videoSlot variable in the VPAIDAdUnit.js file), but everywhere I seem to add this causes a huge failure in testing, mostly related to resetting the snapshot on failures.

Any insight into a resolution to this would be awesome.

alex-phillips commented 8 years ago

I think its worth mentioning that since there is no way (that I can find) to determine which tech a source requires to be played, we would need to call player.reset() so that it starts at the beginning when determining which tech to use for the preroll. Once this is called, the check to determine if the source changed (on whether or not the snapshot needs to be applied or not) is no longer necessary. If we call reset, we'll ALWAYS need to reset the snapshot since the player will lose the source regardless if the preroll was actually played or not.