How to create an interactive YouTube Video selection in VUE

In this blog post I want to share my observations during my implementation of an interactive YouTube Video selection in VUE. Maybe this can save you some time, if you plan to do the same.

Let’s start with my motivation, it came from the improvements of the #BlueCloudMirror game UI. We decided to provide the #BlueCloudMirror users a recorded YouTube LiveStream of us. This video provides an awesome overview of our  major technologies.

The video takes approximately 50 minutes. This is a long time to watch, so we want to provide the user a new interactive architecture page, as you can see below. A user should have the ability to select the topic he is interested in. To do this, we needed the position selection for the YouTube video. In the gif you can see the result.


Topics of this blog post:

  • How to define dynamic values in a VUE template
  • How to configure autostart for YouTube videos
  • How to avoid SAMEORI problem with the YouTube video

How to define dynamic values in a VUE template

You can find the code of the Architecture.vue fileon github.
For the UI I used the option template, and for the event handling the options methods and data.

To show you a high level view of how the code works,  I made a very simplified sequence diagram.


Details of the sequence diagram:

1. v-bind onClick event

The following code shows that the VUE template contains the button. This button will trigger an event. The definition for this event is defined using v-on together with the related method  “onYouTubeDemo.

         background-color: #FFFFFF;
 ><fontcolor="black">Game demo [5:03 mins]</font>

2. Set the right value for “Game Demo”

The method “onYouTubeDemo” is called by clicking the button we defined before. Inside this method, the internal json array variable sets the right youtube video url, for using in the template for the UI later.

In the following code, you can see the internal json array variable definition of “youtubedata”. The json array reflects the properties to display the video in iFrame later.

var youtubedata = {






    allow:"accelerometer; autoplay; encrypted-media; gyroscope;  picture-in-picture",




Inside the code below, in methods, the event method “onYouTubeDemo” is responsible for setting the right video url for the previouly defined json array variable “youtubedata”. The variable is used in the data option later.

methods: {

onYouTubeDemo() {


Data organizes the data exchange for the web frontend with these variables youtubeJSON:youtubedata.  You can find more details  in the VUE best practices.
data: function () {

return {




2. Show the video in iFrame

With the v-bind  and key, and v-for we are setting the right data values for the YouTube video to display inside iFrame. Here you can find the variable youtubeJSON. The blog post Use JSON to dynamically build web pages with Vue.js is awesome help for more details.

   v-for="data in youtubeJSON"

How to configure autostart for the youtube video

I discovered on the internet: you have to ensure that the youtube url contains the parameter autoplay and the value is set to 1.


How to avoid the SAMEORI problem

The SAMEORI problem is our case is, when you cannot display the video in a iFrame. To avoid the SAMEORI problem, simply ensure you use “embed” in your youtube url in the source code. A very useful note is on stack overflow related to the “sameori” error.


This was all about my observations during my implementation of an interactive YouTube Video selection in VUE.

I hope this was useful for you and let’s see what’s next?



PS and FYI … You can use the IBM Cloud for free just create a IBM Lite Account only a email is requested.

#VUE, #SAMEORI, #javascript, #IBMDeveloper, #BlueCloudMirror

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at

Up ↑

%d bloggers like this: