0

I am a user of Wistia and therefore do not have access to the creation of the website, but I would like all the videos in the current playlist to play one after the other.

For this I have inserted a script using requestly.io, which looks like this:

window._wq = window._wq || []
_wq.push({
  id: '_all',
  onReady: function (video) {
    // start the video but with no sound
    video.play()

    // click on next lecture link
    video.bind('end', function () {
      console.log('video end & next')
      document.querySelector('a.smart-next__link--small').click()
    })
  }
})

In principle, it just stimulates the click on the link for the next video as soon as the current video ends.
This also works without any problems.

Only unfortunately the new video starts without sound 'silentAutoPlay'.

If I understand the documentation of the Wistia API correctly, I as a user cannot change this either.
https://wistia.com/support/developers/embed-options#silentautoplay

So I thought it would work if I simmulate the mouse click or the keycode (space) using javascript:

console.log(document.querySelector('[aria-label="Klicken Sie hier, um den Ton einzuschalten"]').parentElement).dispatchEvent(new MouseEvent('click', { bubbles: true }));
document.querySelector('[id^="w-vulcan-v2-"]').dispatchEvent(new KeyboardEvent('keydown',{'keyCode':32,'which':32,'key': " ", 'charCode': 0,}));
// or
document.querySelector('body').dispatchEvent(new KeyboardEvent('keydown',{'keyCode':32,'which':32,'key': " ", 'charCode': 0,}));

This also works in the console of the browser, but not if I included it in the script:

window._wq = window._wq || []
_wq.push({
  id: '_all',
  onReady: function (video) {
    // start the video but with no sound
    video.play()

  setTimeout(() => {
    document.querySelector('[aria-label="Klicken Sie hier, um den Ton einzuschalten"]').parentElement.dispatchEvent(new MouseEvent('click', { bubbles: true }));
    document.querySelector('body').dispatchEvent(new KeyboardEvent('keydown',{'keyCode':32,'which':32,'key': " ", 'charCode': 0,}));
  }, 1500);
    // click on next lecture link
    video.bind('end', function () {
      console.log('video end & next')
      document.querySelector('a.smart-next__link--small').click()
    })
  }
})

Is there any way to get it done?

kolja
  • 505
  • 7
  • 24

0 Answers0