Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


isPrepared

Returns whether the VideoPlayer has successfully prepared the content to be played.
Read time 1 minuteLast updated 10 days ago

Definition

public bool isPrepared { get; }

Remarks

A prepared VideoPlayer can play back the content instantly because preliminary parsing and buffering has been done.
A VideoPlayer starts out as not prepared (
false
). To prepare the VideoPlayer, you need to use VideoPlayer.Prepare. When preparation is done, the VideoPlayer emits the _prepareCompleted event, which sets isPrepared to true.
The property goes back to false when you or the VideoPlayer calls VideoPlayer.Stop.
If there are preparation failures, this property might never be set to true. In this case, Unity sends an error description through the _errorReceived event.
Additional Resources: VideoPlayer.Prepare

Examples

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 prepare a video. public class IsPreparedExample : MonoBehaviour{ public IEnumerator Start() { VideoPlayer videoPlayer = GetComponent<VideoPlayer>(); videoPlayer.Prepare(); // Loops until the video is ready. // Then outputs the message to the console when the preparation is done. while (!videoPlayer.isPrepared) { yield return null; } Debug.Log("Preparation completed!"); }}