I've set up a site for watching videos I've uploaded to YouTube. I'm currently using multiple html docs with each different video which is inconvenient. I'm wondering if there's a way I could read the URL of the video from a .xml file and run every video off one html doc instead of the 10 I have at the moment. (Or if anyone has a better suggestion of how to do it I would appreciate that just as much.) Cheers
-
Could you please give some more information about what technologies you have available? Are the html files you are talking about regular static html files or are they generated by some server-side technology? – Geoffrey De Vylder Apr 11 '17 at 11:24
-
They're just static html files, I'm fairly new to this, please forgive if I'm ignorant – Arrangatang Apr 11 '17 at 11:26
2 Answers
Of course thats possible, just think about an xml structure to store your urls
example might be:
<videos>
<video>
<url>youtube.com/asdf</url>
<title>First Video</title>
</video>
<video>
<url>youtube.com/ewqe</url>
<title>Secound Video</title>
</video>
</videos>
to read out the videos just iterate over the xml structure in JS and append them to your website or directly print them at page load via php etc.

- 468
- 5
- 18

- 173
- 9
I'm afraid giving a clear answer on this question is hard because it's kind of a big question.
It can't be done with pure HTML so you have two options that both involve learning something new.
If the host you put your site on allows you to use some kind of back-end programming language (PHP for example is very common) you can learn how to render more dynamic html pages and load a video based on some parameter in the URL (?video=1) for example.
If you don't want to go the back-end way you are going to need to look into javascript, which you can use to modify the contents of a html page dynamically. Using this route you can add an embedded youtube video to your page after it has loaded based on some kind of variable.

- 3,963
- 7
- 36
- 56
-
1So far I've managed to figure out using JS buttons to change the youtube URL which is working well. There's obviously some grunt work needing done which I'll get down to, cheers! – Arrangatang Apr 11 '17 at 11:45