using UnityEngine; 
 | 
using System.Collections; 
 | 
using vnxbqy.UI; 
 | 
using UnityEngine.Video; 
 | 
using System; 
 | 
  
 | 
public class MoviePlayer : MonoBehaviour 
 | 
{ 
 | 
    static MoviePlayer m_Instance; 
 | 
    public static MoviePlayer Instance 
 | 
    { 
 | 
        get 
 | 
        { 
 | 
            if (m_Instance == null) 
 | 
            { 
 | 
                var prefab = BuiltInLoader.LoadPrefab("MoviePlayer"); 
 | 
                var go = Instantiate(prefab); 
 | 
                go.name = "MoviePlayer"; 
 | 
                go.transform.position = new Vector3(1000, 4000, 1000); 
 | 
                m_Instance = go.GetComponent<MoviePlayer>(); 
 | 
                m_Instance.m_VideoCamera.enabled = false; 
 | 
            } 
 | 
  
 | 
            return m_Instance; 
 | 
        } 
 | 
    } 
 | 
  
 | 
    [SerializeField] VideoPlayer m_VideoPlayer; 
 | 
    [SerializeField] AudioSource m_AudioSource; 
 | 
    [SerializeField] Camera m_VideoCamera; 
 | 
  
 | 
    public bool isPlaying { get; private set; } 
 | 
    Action onComplete; 
 | 
  
 | 
    public void Update() 
 | 
    { 
 | 
        if (Input.GetMouseButtonDown(0)) 
 | 
        { 
 | 
            Stop(); 
 | 
        } 
 | 
    } 
 | 
  
 | 
    public bool Play(string name, Action onComplete) 
 | 
    { 
 | 
        // TODO: Android播放有问题,暂时不用 
 | 
        return false; 
 | 
        //var clip = VideoLoader.Load(name); 
 | 
        //if (clip == null) 
 | 
        //{ 
 | 
        //    return false; 
 | 
        //} 
 | 
        //this.onComplete = onComplete; 
 | 
  
 | 
        //m_VideoPlayer.aspectRatio = VideoAspectRatio.FitInside; 
 | 
        //m_VideoPlayer.clip = clip; 
 | 
        //m_VideoPlayer.SetTargetAudioSource(0, m_AudioSource); 
 | 
        //m_VideoPlayer.Play(); 
 | 
  
 | 
        //m_VideoCamera.enabled = true; 
 | 
        //SoundPlayer.Instance.mute = true; 
 | 
        //isPlaying = true; 
 | 
  
 | 
        //Clock.AlarmAfter(clip.length, () => { Stop(); }); 
 | 
        //return true; 
 | 
    } 
 | 
  
 | 
    public void Stop() 
 | 
    { 
 | 
        if (!isPlaying) 
 | 
        { 
 | 
            return; 
 | 
        } 
 | 
  
 | 
        isPlaying = false; 
 | 
        m_VideoCamera.enabled = false; 
 | 
        SoundPlayer.Instance.mute = false; 
 | 
        if (m_VideoPlayer.isPlaying) 
 | 
        { 
 | 
            m_VideoPlayer.Stop(); 
 | 
            m_VideoPlayer.clip = null; 
 | 
        } 
 | 
  
 | 
        if (onComplete != null) 
 | 
        { 
 | 
            onComplete(); 
 | 
            onComplete = null; 
 | 
        } 
 | 
    } 
 | 
  
 | 
  
 | 
} 
 |