VideoPlayer.isPlaying
Declaration
public bool isPlaying;Описание
Возвращает информацию о том, воспроизводит ли VideoPlayer содержимое в данный момент.
Эта переменная возвращает false, если видео приостановлено. Вызов VideoPlayer.Play не всегда устанавливает для isPlaying значение true. Перед началом воспроизведения объект VideoPlayer должен успешно подготовить содержимое. Чтобы подготовить содержимое перед использованием VideoPlayer.Play, вызовите VideoPlayer.Prepare.
Дополнительные ресурсы: 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(); } } } }