Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot dynamically set the source tag src attribute for YouTube videos. #8630

Open
carlod opened this issue Apr 11, 2019 · 1 comment
Open

Comments

@carlod
Copy link

carlod commented Apr 11, 2019

When trying to dynamically set the src atttribute, of the source tag, I get a return value of null from getElementById("sourceId"). This is due to the DOM manipulation your framework does when it encounters a wb-mltmd class that creates an IFrame to display the YouTube content. With the source tag removed from the DOM I see no way to dynamically set it,

<figure class="wb-mltmd" >
	<video id="videoId3" src="">
		<source id="sourceId" type="video/youtube" src="https://www.youtube.com/watch?v=Stbi6brWAzA" />
	</video>
	<figcaption class="mrgn-tp-md">
		<details id="inline-captions">
			<summary>Video transcript</summary>
		</details>
	</figcaption>
</figure>
@ghost
Copy link

ghost commented Apr 11, 2019

Using the following code I had no issue (there is an unnecessary tag in your HTML <video id="videoId3" src=""> remove src=""):

HTML:

<figure class="wb-mltmd">
  <video id="video" title="YouTube">
		<source id="source" type="video/youtube" src="https://www.youtube.com/watch?v=Stbi6brWAzA" />
	</video>
  <figcaption class="mrgn-tp-md">
    <details id="inline-captions">
      <summary>YouTube</summary>
    </details>
  </figcaption>
</figure>

JavaScript:

const source = document.getElementById("source");
source.src = "http://www.youtube.com/watch?v=9znKJqnFuuY";
source.trigger( "wb-init.wb-mltmd" ); // You'll also need this to reset WET controls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants