MultiChannelDemo2User.cs
2.18 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
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class MultiChannelDemo2User : MonoBehaviour
{
public GUISkin _guiSkin;
public MultiChannelDemo2 _parent;
private AVProWindowsMediaMovie _movie;
private Rect windowRect = new Rect(0, 0, 320, 220);
private float[] _audioMatrixValues;
private Vector2 Position
{
get { return new Vector2((windowRect.x + (windowRect.width / 2)) / Screen.width, windowRect.y / Screen.height); }
}
void Start()
{
_audioMatrixValues = new float[_parent.NumChannels];
windowRect = new Rect(Screen.width / 2, Screen.height / 2, windowRect.width, windowRect.height);
_movie = this.gameObject.AddComponent<AVProWindowsMediaMovie>();
_movie._useAudioMixer = true;
_movie._loadOnStart = false;
_movie._playOnStart = false;
}
void Update()
{
if (_movie.MovieInstance != null)
{
// Generate audio matrix values
_parent.UpdateAudioMatrix(Position, ref _audioMatrixValues);
// Apply matrix values to movie instance
/*for (int i = 0; i < _audioMatrixValues.Length; i++)
Debug.Log("v " + i + " " + _audioMatrixValues[i]);
Debug.Log("apply to " + _movie.MovieInstance.Handle);*/
AVProWindowsMediaPlugin.SetAudioChannelMatrix(_movie.MovieInstance.Handle, _audioMatrixValues, _audioMatrixValues.Length);
}
}
void OnGUI()
{
GUI.skin = _guiSkin;
windowRect = GUI.Window(this.name.GetHashCode(), windowRect, DoMyWindow, this.name);
//GUI.DrawTexture(new Rect(Position.x * Screen.width - (_target.width / 2), Position.y * Screen.height - (_target.height / 2), _target.width, _target.height), _target);
_parent.DrawFalloff(new Vector2(Position.x * Screen.width, (1.0f-Position.y) * Screen.height));
}
void DoMyWindow(int windowID)
{
if (GUILayout.Button("Play Video"))
{
_movie._folder = "";
_movie._filename = "sample-1920x1024-divx.avi";
_movie._useStreamingAssetsPath = true;
_movie._volume = 1.0f;
_movie._loop = true;
if (_movie.LoadMovie(false))
{
_movie.Play();
}
}
if (_movie.OutputTexture)
{
Rect r = GUILayoutUtility.GetRect(320, 180);
GUI.DrawTexture(r, _movie.OutputTexture, ScaleMode.ScaleToFit);
}
GUI.DragWindow();
}
}