videojs / videojs-contrib-ads

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

Cannot read property 'suppressedTracks' of undefined on desktop browsers with HLS live stream #506

Open Dzoge opened 4 years ago

Dzoge commented 4 years ago

Greetings!

I ran into an issue with HLS live stream not switching back to playback after the ad is finished. The following error is logged: ERROR: TypeError: Cannot read property 'suppressedTracks' of undefined referring to player.ads.snapshot object in restorePlayerSnapshot function of videojs-contrib-ads plugin.

But this happens only on my desktop browsers and does not happen on my iPhone (Safari, Chrome). Unfortunately I do not have aaccess to an Android phone at the moment.

I tested on the latest Chrome and Firefox on desktop:

I found a similar issue #173 but that's closed and looks like this is a different case.

I am using videojsx-vast-plugin for ads with the latest versions of:

I have setup the examples:

This is my setup:

<video-js id=vid1 width=600 height=300 class="vjs-default-skin" controls autoplay data-setup='{"autoplay":true}'>
    <source src="https://imedi-tv.cdn.xsg.ge/imedihd/index.m3u8" type="application/x-mpegURL" />
</video-js>
<div id="companion"></div>
<script>
    var player = videojs('vid1');
    player.vast({
        url: 'https://ads.imedi.ge/api/vast/?zone=137',
        skip: 5,
        companion: {
            elementId: "companion",
            maxWidth: 300,
            maxHeight: 250
        }
    });
</script>
danshando commented 4 years ago

@Dzoge did you ever get this figured out. I'm having what looks to be the same or similar issue: TypeError: undefined is not an object (evaluating 'a.suppressedTracks')

The error happens when endLinearAdMode is called for me.

Dzoge commented 4 years ago

@Dzoge did you ever get this figured out. I'm having what looks to be the same or similar issue: TypeError: undefined is not an object (evaluating 'a.suppressedTracks')

The error happens when endLinearAdMode is called for me.

I ended up using old version of some libraries and managed to make it work. Can’t remember the details though.

danshando commented 4 years ago

Okay great, thanks for the reply.

danrossi commented 4 years ago

I get this also. live HLS refuses to return and play back. Stuck in pending on the master playlist.

elkhatibmsi commented 3 years ago

Has` anyone been able to solve this? I am getting the same issue when attempting to run a preroll video before an hls stream. Here is my markup and code (Codepen eg: https://codepen.io/elkhatibmsi/pen/BaKwVVx).

FYI I am using the boilerplate provided by the videojs-contrib-ads documentation: http://videojs.github.io/videojs-contrib-ads/integrator/getting-started.html.

<script src="https://vjs.zencdn.net/7.6.0/video.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-ads/6.7.0/videojs-contrib-ads.js"></script>
<link href="https://vjs.zencdn.net/7.8.4/video-js.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-ads/6.3.0/videojs-contrib-ads.css" rel="stylesheet" type="text/css">

<video id="webcam" class="video-js vjs-default-skin" controls width="640" height="264">
  <source src="https://nzp-ms05.si.edu/live_edge_elephant/elephant01_all.smil/playlist.m3u8" type="application/x-mpegurl" />
</video>
<script>
videojs('webcam', {}, function(){
  var player = this;
player.ads(); // initialize videojs-contrib-ads

// request ads whenever there's new video content
player.on('contentchanged', function() {
  // in a real plugin, you might fetch new ad inventory here
  player.trigger('adsready');
});

player.on('readyforpreroll', function() {
  player.ads.startLinearAdMode();
  // play your linear ad content
  // in this example, we use a static mp4
  player.src('https://images.all-free-download.com/footage_preview/webm/dragonfly_17.webm');

  // send event when ad is playing to remove loading spinner
  player.one('adplaying', function() {
    player.trigger('ads-ad-started');
  });

  // resume content when all your linear ads have finished
  player.one('adended', function() {
    player.ads.endLinearAdMode();
  });
});
// in a real plugin, you might fetch ad inventory here
player.trigger('adsready');
});
</script>
afief commented 3 years ago

Hi everyone, I got this issue only when the main source is live stream and able to fix it by adding liveCuePoints to ads() initialization as mentioned in their documentation http://videojs.github.io/videojs-contrib-ads/integrator/options.html

player.ads({
  liveCuePoints: false
});