Embed (dynamic) YouTube video

0
Hi all, I am trying to embed a YouTube video. I succeeded in embedding a static YouTube video via a HTML snippet, but now I'm trying to make it dynamic. As it is not possible to use parameters in a HTML snippet I searched for an answer and read that I can use a JavaScript snippet (datasource). This is the HTML code I want to show (but of course with a dynamic YouTube Link instead of ‘https://www.youtube.com/embed/LPLuCGQPd0Y’: <iframe width="560" height="315" src="https://www.youtube.com/embed/LPLuCGQPd0Y" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> How do I make the JavaScript Snippet execute/show this HTML? This is what I thought off so far, but I don't know how to write JavaScript, so hopefully someone can help me make it complete.   // Read YouTube URL var YouTubeURL = "${YouTubeUrl}"; <iframe width="560" height="315" src="YouTubeUrl" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
asked
7 answers
0

You could try the CustromString widget. i can’t find it in the Marketplace (weird), but it works in Mx8.

In this widget you point to a microflow where you can build your iframe string and you can configure it to treat the returned string as html, so you get your string as html (in this case an embedded video) on your page.

answered
1

I've found the answer.

I can just use the ‘formatstring’ widget and use this HTMLcode:

<iframe width="400" height="240" src="${URL}" frameborder="0" allowfullscreen ng-show="showvideo"></iframe>

And define the parameter URL with the YouTube link.

answered
0

Maybe not applicable for your Mendix version you are running but if upgrading to Mx8 is possible for your project, you can then you can use the Video player widget.

answered
0

I'll think you can use a Nanoflow which generates this html code. The code (LPLuCGQPd0Y) of the video you must store in a attribut in a table which can be updated bij a microflow.

answered
0

Sorry, no time to doublecheck but does this videoplayer help:

 

See https://mydemoversion8-sandbox.mxapps.io/p/webcam for an example and also examples of other players. You can download the code on https://github.com/TimvanSteenbergen/MyDemoVersion8

O, the ancient greek version Mx7 (EOL in a couple of months), see https://mydemoversion7-sandbox.mxapps.io/p/webcams/. Less options though.

answered
0

I'm still looking to make it work with the Javascript instead of a Video player to be honest.

answered
0

Thank you for answering this.

answered