I would like to set the YouTube video ID at runtime, rather than at design time. Is there a way to do this?
I would like to set the YouTube video ID at runtime, rather than at design time. Is there a way to do this?
Hello Kal,
Please look at a similar question https://getsatisfaction.com/apperyio/...
Alena, I tried this, but it does not work. Here is what I did:
I set up a YouTube component per the following screen shot:
I use the following code in the Page Load of the page containing the component:
code
Appery('kioskYoutube').attr("data-video-id", localStorage.getItem('youtubeVideoId'));
/code
(I made sure that the localStorage has the right value in youtubeVideoId).
When the player comes up, it says "An error occurred, please try again later". If I use the same video ID statically by entering it into the component properties, it works just fine.
What am I doing wrong?
-Kal.
Hello Kal,
You may use this code:
preAppery('kioskYoutube').attr("src", "https://www.youtube.com/embed/"+ localStorage.getItem('youtubeVideoId') + "?loop=1&enablejsapi=1&origin=https%3A%2F%2Fappery.io");/pre
Evgene, thanks, this works, but I have two problems:
It does not loop, even though your command says loop=1.
It shows the YouTube transport control at the bottom of the video, I would like to hide that.
Thanks,
-Kal.
Kal,
Could you please try this code:
preAppery('kioskYoutube').attr("src", "https://www.youtube.com/embed/"+ localStorage.getItem('youtubeVideoId') + "?autoplay=1&loop=1&controls=0&showinfo=0&playlist="+localStorage.getItem('youtubeVideoId')+"&enablejsapi=1&origin=https%3A%2F%2Fappery.io");/pre
Thanks, Evgene! This works perfectly!