少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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;
        }
    }
 
 
}