summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/Video/XVideoMgr.cs
blob: a8a5f0cfab22ed07cca28b7de650a7fdb3f8e3bd (plain)
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
using UnityEngine;
using XUtliPoolLib;
using System.Collections;
using System;

public class XVideoMgr : MonoBehaviour, IXVideo
{
#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
    public MovieTexture Movie;
#endif

    private XVideo _video = null;
    private AudioSource _audio = null;

    public bool isPlaying { get { return _video != null && _video.isPlaying; } }

    void Start()
    {
#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
        GameObject root = GameObject.Find(@"XGamePoint");

        _video = root.AddComponent<XVideo>();
        _audio = root.AddComponent<AudioSource>();
#endif
    }

    public void Play(bool loop = false)
    {
#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
        {
            _video.Play(Movie, _audio, loop);
        }
#else
        {
            Handheld.PlayFullScreenMovie("CG.mp4", Color.black, FullScreenMovieControlMode.CancelOnInput, FullScreenMovieScalingMode.AspectFit);
        }
#endif
    }
#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
    void Update()
    {
        if (_video.isPlaying && Input.GetMouseButtonUp(0))
        {
            _video.Stop();
        }
    }
#endif
    public void Stop()
    {
#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
        {
            if (_video != null) _video.Stop();
        }
#endif
    }

    public bool Deprecated
    {
        get;
        set;
    }
}