Random YouTube Video Embed

Hello,

A little context: my app is built around tablets that show ads

I have tablets (in kiosk mode) that show my “running-ads” page.

In order to change the ads, I send parameters to the page.

So it looks like www.blabla.com/running-ads&ad=1699889968671x164890801309745150

Each AD has a refresh period.
Each tablet showing ads has a “timer”.
When the Tablets-Timer > Ad-Refresh-Period

Then we go to the next ad: thus the page does not refresh, I just change the page parameters to “ad=12312313some31different1231ad1231unique1231id”

NOW - at first I only had static images and I figured out how to work with them.

But I also added YouTube Video ads.

That also worked fine.

The problem starts here I wanted to have multiple YouTube videos under the same AD, and when this AD comes on, the YouTube video should be random.

“youtube” under AD is just a List of texts

This solution has a simple problem: indeed the YouTube Ad is RANDOM but just once. Whenever the link parameter ad= is back to this ad, it’s always the same video.

If I refresh the page “running-ads” - it might be again a random YouTube Video. Until there is another refresh, it’s the same video over and over again.

My second solution

I had this similar problem with having multiple images under the same ad and requesting random images whenever this ad comes back on screen - and I made it work with setting a different state to my image everytime the page is loaded.

It’s not perfect, but it works. I can see the image “change” very fast when this ad comes back.

I thought this solution would work with my YouTube videos too, but it just doesn’t.

What happens is weird: sometimes the Video changes, sometimes it doesnt - but when it doesn’t, it doesnt “restart” the video, it continues playing the video from where it last was - thus sometimes it’s just a youtube thumbnail with the video over.

I’m not sure I was clear enough, but i’m willing to answer all questions.

BIG question is: how do I make my AD show a random YouTube video everytime my page parameter changes?

Thank you!