Audio and my video are not syncing

Is there a way i can check if the file is loaded and then play my audio along with it?

My code so far here

 this.HDaudioVideoSyncButton.button.on('click', function () {
        document.body.appendChild(videoContainer);
        video.src=this.HDaudioVideoSync.getFileUrl();
        video.volume=0;
        sound.src=this.StandardAudio.getFileUrl();
        video.currentTime = 0;
        video.play();
          if(video.play())
              {
                 sound.play(); 
                  console.log('hit here');
              }
          else
              {
                  sound.pause();
              }

    }, this);

But for some reason the audio plays and then the video loads.

Any solutions? Thanks in advance

It looks like you are aren’t waiting the for the video to be buffered yet before playing so the video starts late.

The API for video elements events are here <video>: The Video Embed element - HTML: HyperText Markup Language | MDN

1 Like

Oh yeah thanks @yaustar that fixed my issue only to get stuck on another one. It seems like when i want to fast forward the video/audio the audio does skip the set frame given by me but the video always starts from the beginning.

 this.BackwardSyncButton.button.on('click', function () {
             video.currentTime -=this.frameSkipFactor;
            sound.currentTime -=this.frameSkipFactor;
        }, this);

Thanks in advance!!

Hi @Anush_Praveen,

Are you saying that whenever you set currentTime to any value, the video always goes back to the beginning?

yup and i still couldnt figure that out tho for some reason.

You’re in luck!

I just had this problem. Is you video being hosted on your own server? Try testing setting currentTime in Firefox if you are using Chrome. If it works in Firefox then the problem is that the server is not sending back the “Accept-Ranges” header when it provides the file, so Chrome assumes that it cannot scrub the video and ask for specific parts if it needs it.

For testing purpose i have uploaded some full hd files and a small 2k video in but as far as skipping 2k is almost giving me audio/video mismatch but i’ll try your method right away. Thanks!!