PetroFrolov / vast-video-js

VAST-Ad plugin for HTML5 by video.js
79 stars 33 forks source link

Content video restarts after mid-roll on Safari #29

Open sagarsg opened 10 years ago

sagarsg commented 10 years ago

Hi,

I am able to see this particular intermittent issue on Safari v 6.0.5.

The content video restarts after the mid-roll ad playback. The code in 'seekToOriginalPoint' is setting the time to zero.

var currtime = this.enforcePrecision(startplayback, 0); this.player.currentTime(currtime);

I see this behavior only on Safari. Can you please help me resolve this.

Thanks in advance.

sagarsg commented 10 years ago

Hi,

Did anyone fix the restart issue?

Can I use the 'loadedalldata' event to set the currentTime after mid-roll ad?

this.player.addEvent('loadedalldata', this.player.currentTime(this.enforcePrecision(_v.tempTime,1)));

I am unable to narrow down the problem that is causing content video restart.

I appreciate your time and effort in helping me solve this issue.

sagarsg commented 10 years ago

Hi,

Bug fix -I was able to solve the Safari restart issue by adding the event 'loadeddata'. Trying to set the time before the content is loaded sets the time to zero.

/**
 * 
 */
seekToOriginalPoint: function () {
    var _v = this.player.values;
    var _f =  _V_.proxy(this, this.seekToOriginalPoint);
    this.player.removeEvent('canplaythrough', _f);
    this.player.removeEvent('canplay', _f);
    this.player.removeEvent('loadeddata', _f);
    this.player.removeEvent('loadedmetadata', _f);
    this.player.addEvent('loadeddata', _V_.proxy(this, this.setCurrTime));
    if (_v.paused) {
        _v.paused = false;
    } 
    this.player.addEvent('timeupdate', _V_.proxy(this, this.showAdSlots));
},

/**
 * 
 */
setCurrTime: function () {
    var time = +(this.player.values.tempTime).toFixed(0);
    this.player.currentTime(time);
    this.player.play();
    this.player.removeEvent('loadeddata', _V_.proxy(this, this.setCurrTime));
},
PetroFrolov commented 10 years ago

Hi! I don't have OSX-devices, so I can't check or fix that bug. But I think that you way is wrong. I suppose that removing event loadmetadata (without your code) will fix the bug.

http://www.w3schools.com/tags/av_event_canplay.asp

Can you check my assumption?

sagarsg commented 10 years ago

Sure. I will test it with event oncanplay.

Can I trouble you to give me some more details as to why my approach is wrong. Just want to understand the events better.

Thank you. I appreciate your time.

PetroFrolov commented 10 years ago

Your fix is correct but .. you trey to check loaded data twice. If you take a look at url in previous my post you'll see that the first event we need is loaddata, not loadmetadata (info about video is loaded, but data is not loaded).

sagarsg commented 10 years ago

Thank you for the quick response. I tried it on Safari 6.0.5 but I still see the intermittent behavior. Also, Safari browser on iPhone and iPad, I can see that the content video restarts.

I appreciate your time and effort. Can you please help me resolve this?

Thank you.