JSON Script example to create a Sezion Video Template with flexible Duration / Play property

Flexible video Duration and Play property when creating video Templates with Sezion

In this tutorial you will learn how to play creatively with the Play property when creating a Sezion video template with the JSON Script. The Play property determines when an object or event is being displayed.

When creating personalized videos, sometimes you won’t know the exact millisecond in which an object or event needs to be shown. But you can use as reference other objects within the script. Let’s see this with an example: let’s say you want to create a video template in which one object (image, text, audio or even another video) needs to be automatically displayed after another object, but you don’t know what’s the video duration for the first object because it is a Dynamic Media (which means that it is a personalized input coming from outside Sezion – i.e: a data base). This would be the order for this example:

  1. video_1 (the first media to be displayed)
  2. video_2 (the second media to be automatically displayed when Video_1 has been displayed)

The solution is to use the property Play creatively, such as stating “I want Video_2 to be played when video_1 has finished”. We do this as follows:

"play": "video_1.end",

So, the general structure will be:

“play”: “OBJECT_ID.when“,

For the “when” field you have two options:

  1. start
  2. end

Let’s now go one step further. We can also tell the Sezion platform, “I want video_2 to be played one second before the end of video_1”. We do this as follows:

"play": "video_1.end-1000",

Remember that the time unit in Sezion in milliseconds. That is, one second is equal to 1000 milliseconds.

Here you will find the complete template that I show in the video (you only need to add your own videos):

[
  {
    "video": {
      "id": "video_1",
      "play": 0,
      "zIndex": 2,
      "alpha": 0,
      "events": [
        {
          "start": {
            "imageFadeIn": 0
          }
        },
        {
          "end - 0": {
            "imageFadeOut": 0
          }
        }
      ],
      "loop": false,
      "size": {
        "h": 1,
        "w": 1
      }
    }
  },
  {
    "video": {
      "id": "video_2",
      "play": "video_1.end-1000",
      "duration": 10000,
      "zIndex": 1,
      "alpha": 0,
      "imageAlignH": "center",
      "imageAlignV": "center",
      "imageAspect": "preserve",
      "events": [
        {
          "start": {
            "imageFadeIn": 0
          }
        },
        {
          "end - 0": {
            "imageFadeOut": 0
          }
        }
      ],
      "loop": false
    }
  }
]