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

VideoPlayer.Play

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 Play();

Description

Starts or resumes the playback of a video.

If the video isn't prepared, this method will prepare the video before it starts playback, but playback won't be instant. To make playback instant, use VideoPlayer.Prepare and wait for preparation to finish (when VideoPlayer.prepareCompleted fires), before you use this method.

If you use VideoPlayer.Prepare and then play the video before preparation finishes, the VideoPlayer will finish preparation and then play the video.

Additional resources: VideoPlayer.isPlaying, VideoPlayer.Pause, VideoPlayer.started.

using UnityEngine;
using UnityEngine.Video;

public class PlayExample : MonoBehaviour { void Start() { // Get the VideoPlayer attached to this GameObject. // You need to attach a VideoPlayer component in the Inspector for this script to work. var videoPlayer = GetComponent<VideoPlayer>();

videoPlayer.Play();

} }