AVProWindowsMediaControlPlayOnEnable.cs
2.05 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
using UnityEngine;
using System.Collections;
//-----------------------------------------------------------------------------
// Copyright 2012-2016 RenderHeads Ltd. All rights reserved.
//-----------------------------------------------------------------------------
public class AVProWindowsMediaControlPlayOnEnable : MonoBehaviour
{
public AVProWindowsMediaMovie _movie;
public bool _rewindOnDisable;
public int _minFrame = -1;
public int _maxFrame = -1;
public bool _loop;
public bool _enableLoopWhenInRange;
// TODO: video sequencer
// play until frame 50
// wait
// play range 30-40 looped, with pause of 5 seconds
// pause
/*
void Update()
{
if (_loop)
{
if (_movie.MovieInstance != null)
{
if (_movie.MovieInstance.DisplayFrame >= _maxFrame)
{
_movie.MovieInstance.PositionFrames = (uint)_minFrame;
}
}
}
}*/
void OnEnable()
{
if (!_enableLoopWhenInRange)
{
if (_movie.MovieInstance != null)
{
_movie.MovieInstance.SetFrameRange(_minFrame, _maxFrame);
}
}
else
{
_movie._loop = true;
}
_movie.Play();
}
void Update()
{
if (_enableLoopWhenInRange)
{
if (_movie.MovieInstance != null && _movie.MovieInstance.IsPlaying)
{
if (!_loop)
{
if (_movie.MovieInstance.DisplayFrame >= _minFrame)
{
_movie.MovieInstance.SetFrameRange(_minFrame, _maxFrame);
_loop = true;
}
}
else
{
if (_movie.MovieInstance.DisplayFrame >= _maxFrame)
{
_movie.MovieInstance.PositionFrames = (uint)_minFrame+1;
}
}
}
}
}
void OnDisable()
{
if (_enableLoopWhenInRange)
{
_loop = false;
if (_movie.MovieInstance != null)
{
_movie.MovieInstance.SetFrameRange(-1, -1);
}
}
if (_rewindOnDisable)
{
if (_movie.MovieInstance != null)
{
if (_movie.MovieInstance.IsPlaying)
_movie.Pause();
if (_movie.MovieInstance.DisplayFrame > 1)
_movie.MovieInstance.Rewind();
//AVProWindowsMediaPlugin.FlushFrameBuffers(_movie.MovieInstance.Handle);
}
}
}
}