googleads / videojs-ima

IMA SDK Plugin for Video.js
Apache License 2.0
450 stars 284 forks source link

IMA SDK time bug, clickable bug, playback back with some VAST #934

Closed Barahten closed 4 years ago

Barahten commented 4 years ago

In the latest version of the plugin, I see the following problems when working with some VAST

  1. Time is displayed as -1: -1
  2. Play / pause does not work. A click on the button runs, no errors are displayed in the console, but the ad playback does not pause
  3. The clickable link is not loaded immediately, but after some time: in the example, click on the player and, as soon as the advertisement starts, move the mouse over the player. At first the cursor will be an arrow. then after a while becomes a pointer

Example here http://jsfiddle.net/3f72qmu6/3/

Kiro705 commented 4 years ago

Hello @Barahten ,

It looks like there are a few issues in your jsfiddle implementation.

I would look to the following code simplified from the plugin's simple example to resolve your issues.

var player = videojs('content_video');

var options = {
  id: 'content_video',
  adTagUrl: 'http://pubads.g.doubleclick.net/gampad/ads?sz=640x480&' +
      'iu=/124319096/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&' +
      'impl=s&gdfp_req=1&env=vp&output=xml_vmap1&unviewed_position_start=1&' +
      'cust_params=sample_ar%3Dpremidpostpod%26deployment%3Dgmf-js&cmsid=496&' +
      'vid=short_onecue&correlator='
};

player.ima(options);

// Initialize the ad container when the video player is clicked, but only the first time it's clicked.
var initAdDisplayContainer = function() {
  player.ima.initializeAdDisplayContainer();
  wrapperDiv.removeEventListener('click', initAdDisplayContainer);
}

var wrapperDiv = document.getElementById('content_video');
wrapperDiv.addEventListener('click', initAdDisplayContainer);

Please let me know if you have any other questions.

Barahten commented 4 years ago

Hello, @Kiro705 Yes, it seems to have helped. Thank

Barahten commented 4 years ago

Hey. I decided not to create a new Issue, I will ask here. Is it possible to get CuePoint if the player is set to Autoplay?

I've updated the example. If the player is set to Autoplay, then advertising markers are not displayed until you click on any player control. Run the example and do not click on any player control, wait until the ad finishes playing. Then, after the ad ends, the main video will start playing. If you click on a button, for example, Pause, then ad markers will appear on the timeline.

This example works fine with manually starting the player, but not with Autoplay. Are there any ways to fix this problem? Thanks in advance

if Autoplay doesn't work, start the player manually. Then run the example again (Run button on top left)

Example http://jsfiddle.net/gtc30q74/

Kiro705 commented 4 years ago

Hello @Barahten ,

The reason the markers are not displayed, is that the initAdDisplayContainer function is only being called when the adUi is clicked. I would recommend moving the initAdDisplayContainer function to an initiation step, so it is called every time and not just on clicks.

Barahten commented 4 years ago

Hello @Barahten ,

The reason the markers are not displayed, is that the initAdDisplayContainer function is only being called when the adUi is clicked. I would recommend moving the initAdDisplayContainer function to an initiation step, so it is called every time and not just on clicks.

Hey. Sorry, I didn't quite understand you: to the step of launching what? Could you show the simplest example?

Kiro705 commented 4 years ago

Launching the page or application, or something that happens every time the page loads. The way it was set up in the example, it was only called on click, so if the user never clicked, the markers could not be set.

Using one of the plugin ad events may be a way to make sure this is called on every ad request.

Barahten commented 4 years ago

Launching the page or application, or something that happens every time the page loads. The way it was set up in the example, it was only called on click, so if the user never clicked, the markers could not be set.

Using one of the plugin ad events may be a way to make sure this is called on every ad request.

what event do you recommend to hang this function? Can you give a short example?

Kiro705 commented 4 years ago

I would recommend doing this once an ad request is made:

this.player.on('ads-manager', function(response){
  initAdDisplayContainer();
})