Version: Unity 6.1 Alpha (6000.1)
LanguageEnglish
  • C#

VideoPlayer.StepForward

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public void StepForward();

Description

Immediately advance the current time by one frame.

If the video is currently playing, this method will pause the video before it advances to the next frame. However, if the VideoPlayer isn't prepared, this method will trigger preparation and display the first frame, but will not skip to the next frame. It steps forward from non-initialized to frame 0.

This method is useful if you want to:

  • Analyze each frame of a video.
  • Debug issues related to the video or elements that play at certain frames.
  • Take finer control over the playback speed, because you can choose exactly when the next frame will appear. However, the WebGL implementation is unable to provide frame-accurate control due to platform limitations.
using UnityEngine;
using UnityEngine.Video;
using System.Collections;

// In the Inspector of your GameObject, attach this script and a VideoPlayer component. // Also, assign a VideoClip to your VideoPlayer component. // Use this script to cycle through a video frame by frame.

public class StepForwardExample : MonoBehaviour { VideoPlayer videoPlayer;

public void Start() { videoPlayer = GetComponent<VideoPlayer>(); videoPlayer.Pause(); }

private void Update() { if (Input.GetKeyDown("space") && videoPlayer.isPrepared) { Debug.Log("Space key pressed."); // Go forward one frame in the video when you press the Spacebar. videoPlayer.StepForward(); } } }