0

I have HTML code for two version of video, and I'm trying to change automaticly src of Video 2 with src of Video 1 Video 1 code:

<div id="TopPane5VideoPlayer_TopPlayer">
     <div id="TopPane5VideoPlayer_divInternalT">
           <object type="application/x-shockwave-flash" data="../player.swf?url=Root/Videos/3/17-08-2016/742393_ocean.mp4&amp;volume=90&amp;autoPlay=true&amp;previewImageUrl=../Root/Videos/3/17-08-2016/1920X955742393_ocean.jpg" width="1920" height="955" wmode="opaque" id="video_overlay">
            </object>
       </div>

Video 2:

<div class="sl-video">
<video autoplay>
        <source src="video/trailer.mp4" type="video/mp4; codecs="avc1.42E01E, mp4a.40.2"">
        <source src="video/trailer.webm" type="video/webm; codecs="vp8, vorbis"" />
            Video not supported.
</video>

Rexhep Rexhepi
  • 127
  • 3
  • 13

1 Answers1

0

Try this:

Array.from(document.querySelectorAll('source')).map(x => x.remove())
document.querySelector('video').src = 
  document.querySelector('object').getAttribute('data').match(/url=([^&]+)&/)[1]
Michał Perłakowski
  • 88,409
  • 26
  • 156
  • 177