Set up a video

Note

Xenko supports most major video formats, but converts them to . To reduce compilation time, we recommend you use .mp4 files so Xenko doesn't have to convert them.

Note

Currently, Xenko doesn't support video on iOS platforms.

Before you can use a video in your game, you need to import it as an asset.

  • Drag the video file from Explorer into the Asset View.

    Alternatively, in the Asset View, click Add asset and select Media > Video, then browse to the video you want to add and click Open.

  • If the video has audio tracks, you can import these at the same time, or import just the audio from the video.

Import video

Note

Currently, you can't preview videos in the Asset Preview.

For information about video asset properties, see .

  • In the Scene Editor, select or create an entity to add a video component to.
Tip

It's usually simplest to add the component to the same entity that has the texture plays the video. This just makes it easier to organize your scene.

  • In the Property Grid, click Add component and select Video.

Add video component

Xenko adds a video component to the entity.

  • In the Video properties, under Source, select the video asset.

Video source

  • Under Target, select the texture you want to display the video from.

Models that use this texture will display the video.

When the video isn't playing in your scene, Xenko displays the texture instead.

After you set up the video component, play it from a script using:

  • LoopRange: The looping range (must be an area in the video in PlayRange)
  • IsLooping: Loop the video loop infinitely
  • SpeedFactor: Set the video play speed. 1 is normal speed.
  • PlayState: The current video play state (playing, or stopped)
  • Duration: The duration of the video
  • CurrentTime: The current play time in the video
  • Volume: The audio volume
  • PlayRange: The video start and end time
  • Play/Pause/Stop: Play, pause, or stop the video

Example script

  1. {
  2. {
  3. // Game Studio displays the public member fields and properties you declare in this script
  4. public override void Start()
  5. {
  6. // Initialization of the script.
  7. Entity.Get<VideoComponent>().Instance.Play();
  8. }
  9. }
  • In the Scene Editor, select the entity that has the video component.

Xenko adds the script as a component.

You can adjust in the Property Grid under the script component properties.