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

VideoPlayer.isPlaying

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

public bool isPlaying;

Description

Returns whether the VideoPlayer is currently playing the content.

This variable returns false if the video is paused. If you call VideoPlayer.Play, it might not always set isPlaying to true. The VideoPlayer must successfully prepare the content before it starts to play. To prepare the content before you use VideoPlayer.Play, use VideoPlayer.Prepare.

Additional resources: VideoPlayer.Play, VideoPlayer.isPaused, VideoPlayer.Pause.

// In the Inspector of a GameObject, attach this script and a VideoPlayer component. 

using UnityEngine; using UnityEngine.Video;

public class IsPlayingExample: MonoBehaviour { VideoPlayer videoPlayer;

void Start() { // Get the VideoPlayer component from the GameObject with this script attached. videoPlayer = GetComponent<VideoPlayer>(); }

private void Update() { // Press the Spacebar to pause the video if it's playing. if (Input.GetKeyDown("space")) { // If the VideoPlayer is currently playing a video, pause the video. if(videoPlayer.isPlaying) { videoPlayer.Pause(); } } } }