Embedding a YouTube videoEmbedding YouTube videos on sites is a common requirement, yet the code to do so is typically quite complex, involving IFrames and HTML.
Here we outline a technique that hides all this complexity, and lets a user simply enter the YouTube link, with the system taking care of the rest.
For this example we assume there will be a number of YouTube videos to be embedded.
- Start by creating a Table component, and give it a text field called 'Link'
- Create a Data Entry Form linked to this, and enter some records, each being a typical YouTube link of the form:
https://youtu.be/xxxxxxxxxx - Create a Query component based on the Table, and add the Link field
- In the Format of the Link field, choose Regular Expression, and Import this one:
YouTube regular expression (download this to your local machine first, then Import it to your Regular Express dialog) This will convert the Link format YouTube use into the url they need in an IFrame - Create an IFrame View component, and link it to the Query. Set the 'Source Field' to the Link field, Url as 'Source Field's Content'
Use the IFrame Behaviour Editor's Style dialog to set the desired IFrame size.
Now you can embed the IFrame view on a page to see the embedded video, which can be played in-place.
This is a minimalist example, but you would normally expect to have further fields. That way you could have a Table acting as a central Video library, and then use multiple embeds on different pages, each with different criteria, to show videos around the site.
|