VideoPlayer详解三(暂停、播放、重新播放)

isPlaying:判断视频是否在播放、返回Bool

Play():播放视频

Stop():重新开始播放视频

Pause():暂停视频 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
using UnityEngine.UI;
public class VideoControl : MonoBehaviour {
    private VideoPlayer video;
    void Awake() {
        video = GetComponent();
    }
    void PlayVideo()
    {
        if (!video.isPlaying)
        {
            video.Play();//开始播放
        }
    }
    void PauseVideo()
    {
        if (video.isPlaying)
        {
            video.Pause();//暂停播放
        }
    }
    void StopVideo()
    {
        if (video.isPlaying)
        {
            video.Stop();//重新播放视频
        }
    }
}

 

你可能感兴趣的:(VideoPlayer详解三(暂停、播放、重新播放))