Ejemplo n.º 1
0
    private void Add(string folder, string filename)
    {
        GameObject go = new GameObject();

        go.transform.parent = _root.transform;

        AVProWindowsMediaMovie movie = go.AddComponent <AVProWindowsMediaMovie>();

        movie._folder      = folder;
        movie._filename    = filename;
        movie._loop        = true;
        movie._loadOnStart = false;
        movie._playOnStart = false;

        AVProWindowsMediaGUIDisplay gui = go.AddComponent <AVProWindowsMediaGUIDisplay>();

        gui._movie      = movie;
        gui._scaleMode  = ScaleMode.StretchToFill;
        gui._fullScreen = false;
        gui._alphaBlend = false;
        gui._depth      = 5;
        gui._color      = new Color(0.8f, 0.8f, 0.8f, 1.0f);

        _movies.Add(gui);

        if (!movie.LoadMovie(true))
        {
            Remove(gui);
            return;
        }

        UpdateLayout();
    }
Ejemplo n.º 2
0
    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();
    }
    public void ControlWindow(int id)
    {
        if (_movie == null)
        {
            return;
        }

        GUILayout.Space(16f);

        GUILayout.BeginVertical();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Folder: ", GUILayout.Width(100));
        _movie._folder = GUILayout.TextField(_movie._folder, 192);
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("File: ", GUILayout.Width(100));
        _movie._filename = GUILayout.TextField(_movie._filename, 128, GUILayout.Width(440));
        if (GUILayout.Button("Load File", GUILayout.Width(90)))
        {
            if (!_playFromMemory)
            {
                _movie.LoadMovie(true);
            }
            else
            {
                LoadFileToMemory(_movie._folder, _movie._filename);
            }
        }
        GUILayout.EndHorizontal();


        if (_display != null)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(100f);

            /*if (_display._alphaBlend)
             *      _display._alphaBlend = GUILayout.Toggle(_display._alphaBlend, "Rendering with Transparency");
             * else
             * _display._alphaBlend = GUILayout.Toggle(_display._alphaBlend, "Rendering without Transparency");*/

            if (_display._alphaBlend != GUILayout.Toggle(_display._alphaBlend, "Render with Transparency"))
            {
                _display._alphaBlend = !_display._alphaBlend;
                if (_display._alphaBlend)
                {
                    _movie._colourFormat = AVProWindowsMediaMovie.ColourFormat.RGBA32;
                }
                else
                {
                    _movie._colourFormat = AVProWindowsMediaMovie.ColourFormat.YCbCr_HD;
                }

                if (!_playFromMemory)
                {
                    _movie.LoadMovie(true);
                }
                else
                {
                    LoadFileToMemory(_movie._folder, _movie._filename);
                }
            }



            if (_playFromMemory != GUILayout.Toggle(_playFromMemory, "Play from Memory"))
            {
                _playFromMemory = !_playFromMemory;
                if (_movie.MovieInstance != null)
                {
                    if (!_playFromMemory)
                    {
                        _movie.LoadMovie(true);
                    }
                    else
                    {
                        LoadFileToMemory(_movie._folder, _movie._filename);
                    }
                }
            }

            GUILayout.EndHorizontal();
        }

        AVProWindowsMedia moviePlayer = _movie.MovieInstance;

        if (moviePlayer != null)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Info:", GUILayout.Width(100f));
            GUILayout.Label(moviePlayer.Width + "x" + moviePlayer.Height + " @ " + moviePlayer.FrameRate.ToString("F2") + " FPS");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Volume ", GUILayout.Width(100));
            float volume    = _movie._volume;
            float newVolume = GUILayout.HorizontalSlider(volume, 0.0f, 1.0f, GUILayout.Width(200));
            if (volume != newVolume)
            {
                _movie._volume = newVolume;
            }
            GUILayout.Label(_movie._volume.ToString("F1"));
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            GUILayout.Label("Balance ", GUILayout.Width(100));
            float balance    = _movie._audioBalance;
            float newBalance = GUILayout.HorizontalSlider(balance, -1.0f, 1.0f, GUILayout.Width(200));
            if (balance != newBalance)
            {
                _movie._audioBalance = newBalance;
            }
            GUILayout.Label(moviePlayer.AudioBalance.ToString("F1"));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Audio Delay", GUILayout.Width(100));
            int delay    = moviePlayer.AudioDelay;
            int newDelay = Mathf.FloorToInt(GUILayout.HorizontalSlider(delay, -1000.0f, 1000.0f, GUILayout.Width(200)));
            if (delay != newDelay)
            {
                moviePlayer.AudioDelay = newDelay;
            }
            float msPerFrame = 1000.0f / moviePlayer.FrameRate;
            int   frameDelay = Mathf.FloorToInt((float)newDelay / msPerFrame);
            GUILayout.Label(moviePlayer.AudioDelay.ToString() + "ms (" + frameDelay + " frames)");
            GUILayout.EndHorizontal();



            GUILayout.BeginHorizontal();
            GUILayout.Label("Time ", GUILayout.Width(100));
            float position    = moviePlayer.PositionSeconds;
            float newPosition = GUILayout.HorizontalSlider(position, 0.0f, moviePlayer.DurationSeconds, GUILayout.Width(200));
            if (position != newPosition)
            {
                moviePlayer.PositionSeconds = newPosition;
            }
            GUILayout.Label(moviePlayer.PositionSeconds.ToString("F2") + " / " + moviePlayer.DurationSeconds.ToString("F3") + "s");

            if (GUILayout.Button("Play"))
            {
                moviePlayer.Play();
            }
            if (GUILayout.Button("Pause"))
            {
                moviePlayer.Pause();
            }
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            GUILayout.Label("Frame", GUILayout.Width(100f));

            uint positionFrame = moviePlayer.PositionFrames;
            if (positionFrame != uint.MaxValue)
            {
                uint newPositionFrame = (uint)GUILayout.HorizontalSlider(positionFrame, 0.0f, (float)moviePlayer.LastFrame, GUILayout.Width(200));
                if (positionFrame != newPositionFrame)
                {
                    moviePlayer.PositionFrames = newPositionFrame;
                }

                GUILayout.Label(moviePlayer.PositionFrames.ToString() + " / " + moviePlayer.LastFrame.ToString());

                if (GUILayout.RepeatButton("<", GUILayout.Width(50)))
                {
                    if (moviePlayer.PositionFrames > 0)
                    {
                        moviePlayer.PositionFrames--;
                    }
                }
                if (GUILayout.RepeatButton(">", GUILayout.Width(50)))
                {
                    if (moviePlayer.PositionFrames < moviePlayer.LastFrame)
                    {
                        moviePlayer.PositionFrames++;
                    }
                }

                GUILayout.EndHorizontal();
            }



            GUILayout.BeginHorizontal();
            GUILayout.Label("Rate ", GUILayout.Width(100f));
            GUILayout.Label(moviePlayer.PlaybackRate.ToString("F2") + "x");
            if (GUILayout.Button("-", GUILayout.Width(50)))
            {
                moviePlayer.PlaybackRate = moviePlayer.PlaybackRate * 0.5f;
            }

            if (GUILayout.Button("+", GUILayout.Width(50)))
            {
                moviePlayer.PlaybackRate = moviePlayer.PlaybackRate * 2.0f;
            }
            GUILayout.EndHorizontal();
#if UNITY_EDITOR
            GUILayout.Label("Displaying at " + moviePlayer.DisplayFPS.ToString("F1") + " fps");
#endif
        }

        GUILayout.EndVertical();
    }
	public override void OnInspectorGUI()
	{
		_movie = (this.target) as AVProWindowsMediaMovie;
		
		EditorGUILayout.Separator();
		EditorGUILayout.LabelField("Load Options", EditorStyles.boldLabel);
		//DrawDefaultInspector();

		_movie._folder = EditorGUILayout.TextField("Folder", _movie._folder);
		_movie._filename = EditorGUILayout.TextField("Filename", _movie._filename);
		_movie._useStreamingAssetsPath = EditorGUILayout.Toggle("Use StreamingAssets", _movie._useStreamingAssetsPath);

#if UNITY_EDITOR_WIN
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.PrefixLabel(" ");
		if (GUILayout.Button ("Show File"))
		{
			ShowInExplorer(_movie.GetFilePath());
		}
		EditorGUILayout.EndHorizontal();
#endif
		
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.PrefixLabel("Colour Format");
		_movie._colourFormat = (AVProWindowsMediaMovie.ColourFormat)EditorGUILayout.EnumPopup(_movie._colourFormat);
		EditorGUILayout.EndHorizontal();
		_movie._useDisplaySync = EditorGUILayout.Toggle("Use Display Sync", _movie._useDisplaySync);
		_movie._allowAudio = EditorGUILayout.Toggle("Allow Audio", _movie._allowAudio);
		if (_movie._allowAudio)
		{
			_movie._useAudioDelay = EditorGUILayout.Toggle("Use Audio Delay", _movie._useAudioDelay);
			_movie._useAudioMixer = EditorGUILayout.Toggle("Use Audio Mixer", _movie._useAudioMixer);
		}
		EditorGUILayout.Separator();
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.PrefixLabel("Texture Filter");
		_movie._textureFilterMode = (FilterMode)EditorGUILayout.EnumPopup(_movie._textureFilterMode);
		EditorGUILayout.EndHorizontal();
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.PrefixLabel("Texture Wrap");
		_movie._textureWrapMode = (TextureWrapMode)EditorGUILayout.EnumPopup(_movie._textureWrapMode);
		EditorGUILayout.EndHorizontal();

		EditorGUILayout.Separator();
		EditorGUILayout.Separator();
		EditorGUILayout.LabelField("Start Options", EditorStyles.boldLabel);
		_movie._loadOnStart = EditorGUILayout.Toggle("Load On Start", _movie._loadOnStart);
		_movie._playOnStart = EditorGUILayout.Toggle("Play On Start", _movie._playOnStart);
		EditorGUILayout.Separator();
		EditorGUILayout.Separator();

		EditorGUILayout.Separator();
		EditorGUILayout.Separator();
		EditorGUILayout.LabelField("Performance", EditorStyles.boldLabel);
		_movie._ignoreFlips = EditorGUILayout.Toggle("Ignore Flips", _movie._ignoreFlips);
		EditorGUILayout.Separator();
		EditorGUILayout.Separator();
		
		_movie._loop = EditorGUILayout.Toggle("Loop", _movie._loop);
		//_movie._editorPreview = EditorGUILayout.Toggle("Editor Preview", _movie._editorPreview);		

		if (_movie._allowAudio)
		{
			EditorGUILayout.BeginHorizontal();
			EditorGUILayout.PrefixLabel("Audio Volume");
			_movie._volume = EditorGUILayout.Slider(_movie._volume, 0.0f, 1.0f);
			EditorGUILayout.EndHorizontal();
		}		
		
		GUILayout.Space(8.0f);

        SerializedProperty tps = serializedObject.FindProperty("_clips");
        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(tps, new GUIContent("Clips"), true);
        if (EditorGUI.EndChangeCheck())
        {
            serializedObject.ApplyModifiedProperties();
        }

        GUILayout.Space(8.0f);

		if (!Application.isPlaying)
		{
			EditorGUILayout.BeginHorizontal();
			if (GUILayout.Button("Load"))
			{
				if (AVProWindowsMediaManager.Instance != null)
				{
					_movie.LoadMovie(_movie._playOnStart);
				}
			}

			EditorGUI.BeginDisabledGroup(_movie.MovieInstance == null);
			if (GUILayout.Button("Unload"))
			{
				_movie.UnloadMovie();
			}
			EditorGUI.EndDisabledGroup();
			EditorGUILayout.EndHorizontal();
		}

		AVProWindowsMedia media = _movie.MovieInstance;
		if (media != null)
		{
			GUI.enabled = (_movie != null && _movie.MovieInstance != null);
            _movie._editorPreview = EditorGUILayout.Foldout(_movie._editorPreview, "Video Preview");
			GUI.enabled = true;

            if (_movie._editorPreview && _movie.MovieInstance != null)
			{
				{
					Texture texture = _movie.OutputTexture;
					if (texture == null)
						texture = EditorGUIUtility.whiteTexture;

					float ratio = (float)texture.width / (float)texture.height;


					GUILayout.BeginHorizontal();
					GUILayout.FlexibleSpace();
					Rect textureRect = GUILayoutUtility.GetRect(Screen.width/2, Screen.width/2, (Screen.width / 2) / ratio, (Screen.width / 2) / ratio);
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();

					GUILayout.BeginHorizontal();
					GUILayout.FlexibleSpace();
					_showAlpha = GUILayout.Toggle(_showAlpha, "Show Alpha Channel");
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();
					 
					Matrix4x4 prevMatrix = GUI.matrix;
					if (_movie.MovieInstance.RequiresFlipY)
					{
						GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0, textureRect.y + (textureRect.height / 2)));
					}

					if (!_showAlpha)
						GUI.DrawTexture(textureRect, texture, ScaleMode.ScaleToFit);
					else
						EditorGUI.DrawTextureAlpha(textureRect, texture, ScaleMode.ScaleToFit);

					GUI.matrix = prevMatrix;
				
					GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
					GUILayout.FlexibleSpace();
					if (GUILayout.Button("Select Texture", GUILayout.ExpandWidth(false)))
					{
						Selection.activeObject = texture;
					}
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();

					GUILayout.BeginHorizontal();
					GUILayout.FlexibleSpace();
					GUILayout.Label(string.Format("{0}x{1} @ {2}fps {3} secs", media.Width, media.Height, media.FrameRate.ToString("F2"), media.DurationSeconds.ToString("F2")));		
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();

					GUILayout.BeginHorizontal();
					GUILayout.FlexibleSpace();
					if (media.FramesTotal > 30)
					{
						GUILayout.Label("Displaying at " + media.DisplayFPS.ToString("F1") + " fps");
					}
					else
					{
						GUILayout.Label("Displaying at ... fps");	
					}
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();
				}

				if (_movie.enabled)
				{
					GUILayout.Space(8.0f);

					if (_movie._allowAudio)
					{
						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.PrefixLabel("Audio Balance");
						media.AudioBalance = EditorGUILayout.Slider(media.AudioBalance, -1.0f, 1.0f);
						EditorGUILayout.EndHorizontal();

						EditorGUILayout.Separator();
					}

					EditorGUILayout.LabelField("Frame:");
					EditorGUILayout.BeginHorizontal();
					if (GUILayout.Button("<", GUILayout.ExpandWidth(false)))
					{
						media.PositionFrames--;
					}
					uint currentFrame = media.PositionFrames;
					if (currentFrame != uint.MaxValue)
					{
						int newFrame = EditorGUILayout.IntSlider((int)currentFrame, 0, (int)media.LastFrame);
						if (newFrame != currentFrame)
						{
							media.PositionFrames = (uint)newFrame;
						}
					}
					if (GUILayout.Button(">", GUILayout.ExpandWidth(false)))
					{
						media.PositionFrames++;
					}
					EditorGUILayout.EndHorizontal();

                    if (_movie.NumClips > 0)
                    {
                        EditorGUILayout.Separator();
                        EditorGUILayout.LabelField("Clips", EditorStyles.boldLabel);
                        for (int i = 0; i < _movie.NumClips; i++)
                        {
                            GUILayout.BeginHorizontal();
                            string clipName = _movie.GetClipName(i);
                            GUILayout.Label(clipName);
                            if (GUILayout.Button("Loop"))
                            {
                                _movie.PlayClip(clipName, true, false);
                            }
                            GUILayout.EndHorizontal();
                        }
                        if (GUILayout.Button("Reset Clip"))
                            _movie.ResetClip();
                        EditorGUILayout.Separator();
                    }

					EditorGUILayout.BeginHorizontal();
					if (GUILayout.Button("Rewind"))
					{
						_movie.MovieInstance.Rewind();
					}

					if (!media.IsPlaying)
					{
						if (GUILayout.Button("Play"))
						{
							_movie.Play();
						}						
					}
					else
					{
						if (GUILayout.Button("Pause"))
						{
							_movie.Pause();
						}
					}
					EditorGUILayout.EndHorizontal();

#if !AVPROWINDOWSMEDIA_UNITYFEATURE_EDITORAUTOREFRESH
					this.Repaint();
#endif
				}
			}
        }
		if (GUI.changed)
		{
			EditorUtility.SetDirty(_movie);
		}

        // If the app isn't running but the media is we may need to manually update it
        if (!Application.isPlaying && _movie.MovieInstance != null)
        {
            _movie.Update();
            AVProWindowsMediaManager.Instance.Update();
            EditorUtility.SetDirty(_movie);
        }
	}
    public override void OnInspectorGUI()
    {
        _movie = (this.target) as AVProWindowsMediaMovie;

        EditorGUILayout.Separator();
        GUILayout.Label("File Location", EditorStyles.boldLabel);
        //DrawDefaultInspector();

        _movie._useStreamingAssetsPath = EditorGUILayout.Toggle("Use StreamingAssets", _movie._useStreamingAssetsPath);
        _movie._folder   = EditorGUILayout.TextField("Folder", _movie._folder);
        _movie._filename = EditorGUILayout.TextField("Filename", _movie._filename);

        GUILayout.BeginHorizontal();
        GUI.enabled = System.IO.File.Exists(_movie.GetFilePath());

#if UNITY_EDITOR_WIN
        if (GUILayout.Button("Show"))
        {
            ShowInExplorer(_movie.GetFilePath());
        }
#endif
        GUI.enabled &= _movie._useStreamingAssetsPath;

        if (GUILayout.Button("Select"))
        {
            string projectRoot = System.IO.Path.GetFullPath(System.IO.Path.Combine(Application.dataPath, ".."));
            projectRoot = projectRoot.Replace('\\', '/');

            string path = _movie.GetFilePath();
            path = path.Remove(0, projectRoot.Length + 1);

            Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(path);
        }
        GUILayout.EndHorizontal();
        GUI.enabled = true;

        GUI.color = Color.green;
        if (GUILayout.Button("BROWSE"))
        {
            Browse(Application.streamingAssetsPath, ref _movie._filename, ref _movie._folder, ref _movie._useStreamingAssetsPath);
        }
        GUI.color = Color.white;

        if (string.IsNullOrEmpty(_movie.GetFilePath()))
        {
            if (_movie._loadOnStart)
            {
                GUI.color = Color.red;
                GUILayout.TextArea("Error: No file specfied");
                GUI.color = Color.white;
            }
            else
            {
                GUI.color = Color.yellow;
                GUILayout.TextArea("Warning: No file specfied");
                GUI.color = Color.white;
            }
        }
        else if (!System.IO.File.Exists(_movie.GetFilePath()))
        {
            GUI.color = Color.red;
            GUILayout.TextArea("Error: File not found");
            GUI.color = Color.white;
        }
        else
        {
            if (!_movie._useStreamingAssetsPath)
            {
                GUI.color = Color.yellow;
                GUILayout.TextArea("Warning: Files not in StreamingAssets will require manual copying for builds");
                GUI.color = Color.white;
            }
        }
        if (System.IO.Path.IsPathRooted(_movie._folder))
        {
            GUI.color = Color.yellow;
            GUILayout.TextArea("Warning: Absolute path is not ideal.  Better to use files relative to the project root");
            GUI.color = Color.white;
        }

        GUILayout.Space(10f);

        EditorGUILayout.Separator();
        GUILayout.Label("Load Options", EditorStyles.boldLabel);

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Colour Format");
        _movie._colourFormat = (AVProWindowsMediaMovie.ColourFormat)EditorGUILayout.EnumPopup(_movie._colourFormat);
        EditorGUILayout.EndHorizontal();
        _movie._useDisplaySync = EditorGUILayout.Toggle("Use Display Sync", _movie._useDisplaySync);

        if (_movie._useDisplaySync)
        {
            if (
#if UNITY_5
                PlayerSettings.d3d11FullscreenMode != D3D11FullscreenMode.ExclusiveMode ||
#endif
                PlayerSettings.d3d9FullscreenMode != D3D9FullscreenMode.ExclusiveMode)
            {
                GUI.color = Color.cyan;
                GUILayout.TextArea("Perf: For display sync fullscreen mode should be set to EXCLUSIVE in Player Settings");
                GUI.color = Color.white;
            }
            if (QualitySettings.vSyncCount != 1 && QualitySettings.vSyncCount != 2)
            {
                GUI.color = Color.cyan;
                GUILayout.TextArea("Perf: For display sync vsync must be set to 1 or 2 in Quality Settings");
                GUI.color = Color.white;
            }
        }

        _movie._allowAudio = EditorGUILayout.Toggle("Allow Audio", _movie._allowAudio);
        GUI.enabled        = _movie._allowAudio;
        {
            _movie._useAudioDelay = EditorGUILayout.Toggle("Use Audio Delay", _movie._useAudioDelay);
            _movie._useAudioMixer = EditorGUILayout.Toggle("Use Audio Mixer", _movie._useAudioMixer);
        }
        GUI.enabled = true;

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Texture Filter");
        _movie._textureFilterMode = (FilterMode)EditorGUILayout.EnumPopup(_movie._textureFilterMode);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Texture Wrap");
        _movie._textureWrapMode = (TextureWrapMode)EditorGUILayout.EnumPopup(_movie._textureWrapMode);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Separator();
        EditorGUILayout.Separator();
        EditorGUILayout.LabelField("Start Options", EditorStyles.boldLabel);
        _movie._loadOnStart = EditorGUILayout.Toggle("Load On Start", _movie._loadOnStart);
        GUI.enabled         = _movie._loadOnStart;
        if (!_movie._loadOnStart)
        {
            _movie._playOnStart = false;
        }
        _movie._playOnStart = EditorGUILayout.Toggle("Play On Start", _movie._playOnStart);
        GUI.enabled         = true;
        EditorGUILayout.Separator();
        EditorGUILayout.Separator();

        EditorGUILayout.Separator();
        EditorGUILayout.Separator();
        EditorGUILayout.LabelField("Performance", EditorStyles.boldLabel);
        _movie._ignoreFlips = EditorGUILayout.Toggle("Ignore Flips", _movie._ignoreFlips);
        EditorGUILayout.Separator();
        EditorGUILayout.Separator();

        EditorGUILayout.Separator();
        GUILayout.Label("Playback", EditorStyles.boldLabel);

        _movie._loop = EditorGUILayout.Toggle("Loop", _movie._loop);
        //_movie._editorPreview = EditorGUILayout.Toggle("Editor Preview", _movie._editorPreview);

        GUI.enabled = _movie._allowAudio;
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Audio Volume");
            _movie._volume = EditorGUILayout.Slider(_movie._volume, 0.0f, 1.0f);
            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Audio Balance");
            _movie._audioBalance = EditorGUILayout.Slider(_movie._audioBalance, -1.0f, 1.0f);
            EditorGUILayout.EndHorizontal();
        }
        GUI.enabled = true;

        GUILayout.Space(8.0f);

        SerializedProperty tps = serializedObject.FindProperty("_clips");
        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(tps, new GUIContent("Clips"), true);
        if (EditorGUI.EndChangeCheck())
        {
            serializedObject.ApplyModifiedProperties();
        }

        GUILayout.Space(8.0f);

        if (!Application.isPlaying)
        {
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Load"))
            {
                if (AVProWindowsMediaManager.Instance != null)
                {
                    _movie.LoadMovie(_movie._playOnStart);
                }
            }

#if UNITY_5 && !UNITY_5_0 && !UNITY_5_1 && !UNITY_5_2 && !UNITY_5_3
            using (var scope = new EditorGUI.DisabledScope(_movie.MovieInstance == null))
#else
            EditorGUI.BeginDisabledGroup(_movie.MovieInstance == null);
#endif
            {
                if (GUILayout.Button("Unload"))
                {
                    _movie.UnloadMovie();
                }
            }
#if UNITY_5 && !UNITY_5_0 && !UNITY_5_1 && !UNITY_5_2 && !UNITY_5_3
#else
            EditorGUI.EndDisabledGroup();
#endif

            EditorGUILayout.EndHorizontal();
        }

        AVProWindowsMedia media = _movie.MovieInstance;
        if (media != null)
        {
            GUI.enabled           = (_movie != null && _movie.MovieInstance != null);
            _movie._editorPreview = EditorGUILayout.Foldout(_movie._editorPreview, "Video Preview");
            GUI.enabled           = true;

            if (_movie._editorPreview && _movie.MovieInstance != null)
            {
                {
                    Texture texture = _movie.OutputTexture;
                    if (texture == null)
                    {
                        texture = EditorGUIUtility.whiteTexture;
                    }

                    float ratio = (float)texture.width / (float)texture.height;


                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    Rect textureRect = GUILayoutUtility.GetRect(Screen.width / 2, Screen.width / 2, (Screen.width / 2) / ratio, (Screen.width / 2) / ratio);
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    _showAlpha = GUILayout.Toggle(_showAlpha, "Show Alpha Channel");
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    Matrix4x4 prevMatrix = GUI.matrix;
                    if (_movie.MovieInstance.RequiresFlipY)
                    {
                        GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0, textureRect.y + (textureRect.height / 2)));
                    }

                    if (!_showAlpha)
                    {
                        GUI.DrawTexture(textureRect, texture, ScaleMode.ScaleToFit);
                    }
                    else
                    {
                        EditorGUI.DrawTextureAlpha(textureRect, texture, ScaleMode.ScaleToFit);
                    }

                    GUI.matrix = prevMatrix;

                    GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Select Texture", GUILayout.ExpandWidth(false)))
                    {
                        Selection.activeObject = texture;
                    }
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(string.Format("{0}x{1} @ {2}fps {3} secs", media.Width, media.Height, media.FrameRate.ToString("F2"), media.DurationSeconds.ToString("F2")));
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (media.FramesTotal > 30)
                    {
                        GUILayout.Label("Displaying at " + media.DisplayFPS.ToString("F1") + " fps");
                    }
                    else
                    {
                        GUILayout.Label("Displaying at ... fps");
                    }
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }

                if (_movie.enabled)
                {
                    GUILayout.Space(8.0f);

                    EditorGUILayout.LabelField("Frame:");
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("<", GUILayout.ExpandWidth(false)))
                    {
                        media.PositionFrames--;
                    }
                    uint currentFrame = media.PositionFrames;
                    if (currentFrame != uint.MaxValue)
                    {
                        int newFrame = EditorGUILayout.IntSlider((int)currentFrame, 0, (int)media.LastFrame);
                        if (newFrame != currentFrame)
                        {
                            media.PositionFrames = (uint)newFrame;
                        }
                    }
                    if (GUILayout.Button(">", GUILayout.ExpandWidth(false)))
                    {
                        media.PositionFrames++;
                    }
                    EditorGUILayout.EndHorizontal();

                    if (_movie.NumClips > 0)
                    {
                        EditorGUILayout.Separator();
                        EditorGUILayout.LabelField("Clips", EditorStyles.boldLabel);
                        for (int i = 0; i < _movie.NumClips; i++)
                        {
                            GUILayout.BeginHorizontal();
                            string clipName = _movie.GetClipName(i);
                            GUILayout.Label(clipName);
                            if (GUILayout.Button("Loop"))
                            {
                                _movie.PlayClip(clipName, true, false);
                            }
                            GUILayout.EndHorizontal();
                        }
                        if (GUILayout.Button("Reset Clip"))
                        {
                            _movie.ResetClip();
                        }
                        EditorGUILayout.Separator();
                    }

                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("Rewind"))
                    {
                        _movie.MovieInstance.Rewind();
                    }

                    if (!media.IsPlaying)
                    {
                        if (GUILayout.Button("Play"))
                        {
                            _movie.Play();
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("Pause"))
                        {
                            _movie.Pause();
                        }
                    }
                    EditorGUILayout.EndHorizontal();

#if !AVPROWINDOWSMEDIA_UNITYFEATURE_EDITORAUTOREFRESH
                    this.Repaint();
#endif
                }
            }
        }
        if (GUI.changed)
        {
            EditorUtility.SetDirty(_movie);
        }

        // If the app isn't running but the media is we may need to manually update it
        if (!Application.isPlaying && _movie.MovieInstance != null)
        {
            _movie.Update();
            AVProWindowsMediaManager.Instance.Update();
            EditorUtility.SetDirty(_movie);
        }
    }
    public void ControlWindow(int id)
    {
        if (_movie == null)
        {
            return;
        }

        GUILayout.Space(16f);

        GUILayout.BeginVertical();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Folder: ", GUILayout.Width(80));
        _movie._folder = GUILayout.TextField(_movie._folder, 192);
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("File: ", GUILayout.Width(80));
        _movie._filename = GUILayout.TextField(_movie._filename, 128, GUILayout.Width(440));
        if (GUILayout.Button("Load File", GUILayout.Width(90)))
        {
            _movie.LoadMovie(true);
        }
        GUILayout.EndHorizontal();

        bool alphaBlend = _movie._colourFormat == AVProWindowsMediaMovie.ColourFormat.RGBA32;

        if (alphaBlend)
        {
            alphaBlend = GUILayout.Toggle(alphaBlend, "Render with Transparency (requires movie reload)");
        }
        else
        {
            alphaBlend = GUILayout.Toggle(alphaBlend, "Render without Transparency");
        }

        if (alphaBlend)
        {
            _movie._colourFormat = AVProWindowsMediaMovie.ColourFormat.RGBA32;
        }
        else
        {
            _movie._colourFormat = AVProWindowsMediaMovie.ColourFormat.YCbCr_HD;
        }


        AVProWindowsMedia moviePlayer = _movie.MovieInstance;

        if (moviePlayer != null)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Info:", GUILayout.Width(80f));
            GUILayout.Label(moviePlayer.Width + "x" + moviePlayer.Height + " @ " + moviePlayer.FrameRate.ToString("F2") + " FPS");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Volume ", GUILayout.Width(80));
            float volume    = _movie._volume;
            float newVolume = GUILayout.HorizontalSlider(volume, 0.0f, 1.0f, GUILayout.Width(200));
            if (volume != newVolume)
            {
                _movie._volume = newVolume;
            }
            GUILayout.Label(_movie._volume.ToString("F1"));
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            GUILayout.Label("Balance ", GUILayout.Width(80));
            float balance    = moviePlayer.AudioBalance;
            float newBalance = GUILayout.HorizontalSlider(balance, -1.0f, 1.0f, GUILayout.Width(200));
            if (balance != newBalance)
            {
                moviePlayer.AudioBalance = newBalance;
            }
            GUILayout.Label(moviePlayer.AudioBalance.ToString("F1"));
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            GUILayout.Label("Time ", GUILayout.Width(80));
            float position    = moviePlayer.PositionSeconds;
            float newPosition = GUILayout.HorizontalSlider(position, 0.0f, moviePlayer.DurationSeconds, GUILayout.Width(200));
            if (position != newPosition)
            {
                moviePlayer.PositionSeconds = newPosition;
            }
            GUILayout.Label(moviePlayer.PositionSeconds.ToString("F1") + " / " + moviePlayer.DurationSeconds.ToString("F1") + "s");

            if (GUILayout.Button("Play"))
            {
                moviePlayer.Play();
            }
            if (GUILayout.Button("Pause"))
            {
                moviePlayer.Pause();
            }
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            GUILayout.Label("Frame", GUILayout.Width(80f));
            GUILayout.Label(moviePlayer.PositionFrames.ToString() + " / " + moviePlayer.DurationFrames.ToString());

            if (GUILayout.Button("<", GUILayout.Width(50)))
            {
                moviePlayer.Pause();
                if (moviePlayer.PositionFrames > 0)
                {
                    moviePlayer.PositionFrames--;
                }
            }
            if (GUILayout.Button(">", GUILayout.Width(50)))
            {
                moviePlayer.Pause();
                if (moviePlayer.PositionFrames < moviePlayer.DurationFrames)
                {
                    moviePlayer.PositionFrames++;
                }
            }

            GUILayout.EndHorizontal();



            GUILayout.BeginHorizontal();
            GUILayout.Label("Rate ", GUILayout.Width(80f));
            GUILayout.Label(moviePlayer.PlaybackRate.ToString("F2") + "x");
            if (GUILayout.Button("-", GUILayout.Width(50)))
            {
                moviePlayer.PlaybackRate = moviePlayer.PlaybackRate * 0.5f;
            }

            if (GUILayout.Button("+", GUILayout.Width(50)))
            {
                moviePlayer.PlaybackRate = moviePlayer.PlaybackRate * 2.0f;
            }
            GUILayout.EndHorizontal();
        }

        GUILayout.EndVertical();
    }
	public override void OnInspectorGUI()
	{
		_movie = (this.target) as AVProWindowsMediaMovie;

		EditorGUILayout.Separator();
		GUILayout.Label("File Location", EditorStyles.boldLabel);
		//DrawDefaultInspector();

		_movie._useStreamingAssetsPath = EditorGUILayout.Toggle("Use StreamingAssets", _movie._useStreamingAssetsPath);
		_movie._folder = EditorGUILayout.TextField("Folder", _movie._folder);
		_movie._filename = EditorGUILayout.TextField("Filename", _movie._filename);

		GUILayout.BeginHorizontal();
		GUI.enabled = System.IO.File.Exists(_movie.GetFilePath());
		
#if UNITY_EDITOR_WIN
		if (GUILayout.Button("Show"))
		{
			ShowInExplorer(_movie.GetFilePath());
		}
#endif
		GUI.enabled &= _movie._useStreamingAssetsPath;

		if (GUILayout.Button("Select"))
		{
			string projectRoot = System.IO.Path.GetFullPath(System.IO.Path.Combine(Application.dataPath, ".."));
			projectRoot = projectRoot.Replace('\\', '/');

			string path = _movie.GetFilePath();
			path = path.Remove(0, projectRoot.Length + 1);
					
			Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(path);
		}
		GUILayout.EndHorizontal();
		GUI.enabled = true;

		GUI.color = Color.green;
		if (GUILayout.Button("BROWSE"))
		{
			Browse(Application.streamingAssetsPath, ref _movie._filename, ref _movie._folder, ref _movie._useStreamingAssetsPath);
		}
		GUI.color = Color.white;

		if (string.IsNullOrEmpty(_movie.GetFilePath()))
		{
			if (_movie._loadOnStart)
			{
				GUI.color = Color.red;
				GUILayout.TextArea("Error: No file specfied");
				GUI.color = Color.white;
			}
			else
			{
				GUI.color = Color.yellow;
				GUILayout.TextArea("Warning: No file specfied");
				GUI.color = Color.white;
			}
		}
		else if (!System.IO.File.Exists(_movie.GetFilePath()))
		{
			GUI.color = Color.red;
			GUILayout.TextArea("Error: File not found");
			GUI.color = Color.white;
		}
		else
		{
			if (!_movie._useStreamingAssetsPath)
			{
				GUI.color = Color.yellow;
				GUILayout.TextArea("Warning: Files not in StreamingAssets will require manual copying for builds");
				GUI.color = Color.white;
			}
		}
		if (System.IO.Path.IsPathRooted(_movie._folder))
		{
			GUI.color = Color.yellow;
			GUILayout.TextArea("Warning: Absolute path is not ideal.  Better to use files relative to the project root");
			GUI.color = Color.white;
		}

		GUILayout.Space(10f);

		EditorGUILayout.Separator();
		GUILayout.Label("Load Options", EditorStyles.boldLabel);
		
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.PrefixLabel("Colour Format");
		_movie._colourFormat = (AVProWindowsMediaMovie.ColourFormat)EditorGUILayout.EnumPopup(_movie._colourFormat);
		EditorGUILayout.EndHorizontal();
		_movie._useDisplaySync = EditorGUILayout.Toggle("Use Display Sync", _movie._useDisplaySync);

		if (_movie._useDisplaySync)
		{
			if (
#if UNITY_5
				PlayerSettings.d3d11FullscreenMode != D3D11FullscreenMode.ExclusiveMode || 
#endif
				PlayerSettings.d3d9FullscreenMode != D3D9FullscreenMode.ExclusiveMode)
			{
				GUI.color = Color.cyan;
				GUILayout.TextArea("Perf: For display sync fullscreen mode should be set to EXCLUSIVE in Player Settings");
				GUI.color = Color.white;
			}
			if (QualitySettings.vSyncCount != 1 && QualitySettings.vSyncCount != 2)
			{
				GUI.color = Color.cyan;
				GUILayout.TextArea("Perf: For display sync vsync must be set to 1 or 2 in Quality Settings");
				GUI.color = Color.white;
			}
		}

		_movie._allowAudio = EditorGUILayout.Toggle("Allow Audio", _movie._allowAudio);
		GUI.enabled = _movie._allowAudio;
		{
			_movie._useAudioDelay = EditorGUILayout.Toggle("Use Audio Delay", _movie._useAudioDelay);
			_movie._useAudioMixer = EditorGUILayout.Toggle("Use Audio Mixer", _movie._useAudioMixer);
		}
		GUI.enabled = true;

		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.PrefixLabel("Texture Filter");
		_movie._textureFilterMode = (FilterMode)EditorGUILayout.EnumPopup(_movie._textureFilterMode);
		EditorGUILayout.EndHorizontal();
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.PrefixLabel("Texture Wrap");
		_movie._textureWrapMode = (TextureWrapMode)EditorGUILayout.EnumPopup(_movie._textureWrapMode);
		EditorGUILayout.EndHorizontal();

		EditorGUILayout.Separator();
		EditorGUILayout.Separator();
		EditorGUILayout.LabelField("Start Options", EditorStyles.boldLabel);
		_movie._loadOnStart = EditorGUILayout.Toggle("Load On Start", _movie._loadOnStart);
		GUI.enabled = _movie._loadOnStart;
		if (!_movie._loadOnStart)
			_movie._playOnStart = false;
		_movie._playOnStart = EditorGUILayout.Toggle("Play On Start", _movie._playOnStart);
		GUI.enabled = true;
		EditorGUILayout.Separator();
		EditorGUILayout.Separator();

		EditorGUILayout.Separator();
		EditorGUILayout.Separator();
		EditorGUILayout.LabelField("Performance", EditorStyles.boldLabel);
		_movie._ignoreFlips = EditorGUILayout.Toggle("Ignore Flips", _movie._ignoreFlips);
		EditorGUILayout.Separator();
		EditorGUILayout.Separator();

		EditorGUILayout.Separator();
		GUILayout.Label("Playback", EditorStyles.boldLabel);

		_movie._loop = EditorGUILayout.Toggle("Loop", _movie._loop);
		//_movie._editorPreview = EditorGUILayout.Toggle("Editor Preview", _movie._editorPreview);		

		GUI.enabled = _movie._allowAudio;
		{
			EditorGUILayout.BeginHorizontal();
			EditorGUILayout.PrefixLabel("Audio Volume");
			_movie._volume = EditorGUILayout.Slider(_movie._volume, 0.0f, 1.0f);
			EditorGUILayout.EndHorizontal();

			
			EditorGUILayout.BeginHorizontal();
			EditorGUILayout.PrefixLabel("Audio Balance");
			_movie._audioBalance = EditorGUILayout.Slider(_movie._audioBalance, -1.0f, 1.0f);
			EditorGUILayout.EndHorizontal();
		}
		GUI.enabled = true;
		
		GUILayout.Space(8.0f);

        SerializedProperty tps = serializedObject.FindProperty("_clips");
        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(tps, new GUIContent("Clips"), true);
        if (EditorGUI.EndChangeCheck())
        {
            serializedObject.ApplyModifiedProperties();
        }

        GUILayout.Space(8.0f);

		if (!Application.isPlaying)
		{
			EditorGUILayout.BeginHorizontal();
			if (GUILayout.Button("Load"))
			{
				if (AVProWindowsMediaManager.Instance != null)
				{
					_movie.LoadMovie(_movie._playOnStart);
				}
			}

#if UNITY_5 && !UNITY_5_0 && !UNITY_5_1 && !UNITY_5_2 && !UNITY_5_3
			using (var scope = new EditorGUI.DisabledScope(_movie.MovieInstance == null))
#else
			EditorGUI.BeginDisabledGroup(_movie.MovieInstance == null);
#endif
			{
				if (GUILayout.Button("Unload"))
				{
					_movie.UnloadMovie();
				}
			}
#if UNITY_5 && !UNITY_5_0 && !UNITY_5_1 && !UNITY_5_2 && !UNITY_5_3
#else
			EditorGUI.EndDisabledGroup();
#endif

			EditorGUILayout.EndHorizontal();
		}

		AVProWindowsMedia media = _movie.MovieInstance;
		if (media != null)
		{
			GUI.enabled = (_movie != null && _movie.MovieInstance != null);
            _movie._editorPreview = EditorGUILayout.Foldout(_movie._editorPreview, "Video Preview");
			GUI.enabled = true;

            if (_movie._editorPreview && _movie.MovieInstance != null)
			{
				{
					Texture texture = _movie.OutputTexture;
					if (texture == null)
						texture = EditorGUIUtility.whiteTexture;

					float ratio = (float)texture.width / (float)texture.height;


					GUILayout.BeginHorizontal();
					GUILayout.FlexibleSpace();
					Rect textureRect = GUILayoutUtility.GetRect(Screen.width/2, Screen.width/2, (Screen.width / 2) / ratio, (Screen.width / 2) / ratio);
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();

					GUILayout.BeginHorizontal();
					GUILayout.FlexibleSpace();
					_showAlpha = GUILayout.Toggle(_showAlpha, "Show Alpha Channel");
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();
					 
					Matrix4x4 prevMatrix = GUI.matrix;
					if (_movie.MovieInstance.RequiresFlipY)
					{
						GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0, textureRect.y + (textureRect.height / 2)));
					}

					if (!_showAlpha)
						GUI.DrawTexture(textureRect, texture, ScaleMode.ScaleToFit);
					else
						EditorGUI.DrawTextureAlpha(textureRect, texture, ScaleMode.ScaleToFit);

					GUI.matrix = prevMatrix;
				
					GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
					GUILayout.FlexibleSpace();
					if (GUILayout.Button("Select Texture", GUILayout.ExpandWidth(false)))
					{
						Selection.activeObject = texture;
					}
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();

					GUILayout.BeginHorizontal();
					GUILayout.FlexibleSpace();
					GUILayout.Label(string.Format("{0}x{1} @ {2}fps {3} secs", media.Width, media.Height, media.FrameRate.ToString("F2"), media.DurationSeconds.ToString("F2")));		
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();

					GUILayout.BeginHorizontal();
					GUILayout.FlexibleSpace();
					if (media.FramesTotal > 30)
					{
						GUILayout.Label("Displaying at " + media.DisplayFPS.ToString("F1") + " fps");
					}
					else
					{
						GUILayout.Label("Displaying at ... fps");	
					}
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();
				}

				if (_movie.enabled)
				{
					GUILayout.Space(8.0f);

					EditorGUILayout.LabelField("Frame:");
					EditorGUILayout.BeginHorizontal();
					if (GUILayout.Button("<", GUILayout.ExpandWidth(false)))
					{
						media.PositionFrames--;
					}
					uint currentFrame = media.PositionFrames;
					if (currentFrame != uint.MaxValue)
					{
						int newFrame = EditorGUILayout.IntSlider((int)currentFrame, 0, (int)media.LastFrame);
						if (newFrame != currentFrame)
						{
							media.PositionFrames = (uint)newFrame;
						}
					}
					if (GUILayout.Button(">", GUILayout.ExpandWidth(false)))
					{
						media.PositionFrames++;
					}
					EditorGUILayout.EndHorizontal();

                    if (_movie.NumClips > 0)
                    {
                        EditorGUILayout.Separator();
                        EditorGUILayout.LabelField("Clips", EditorStyles.boldLabel);
                        for (int i = 0; i < _movie.NumClips; i++)
                        {
                            GUILayout.BeginHorizontal();
                            string clipName = _movie.GetClipName(i);
                            GUILayout.Label(clipName);
                            if (GUILayout.Button("Loop"))
                            {
                                _movie.PlayClip(clipName, true, false);
                            }
                            GUILayout.EndHorizontal();
                        }
                        if (GUILayout.Button("Reset Clip"))
                            _movie.ResetClip();
                        EditorGUILayout.Separator();
                    }

					EditorGUILayout.BeginHorizontal();
					if (GUILayout.Button("Rewind"))
					{
						_movie.MovieInstance.Rewind();
					}

					if (!media.IsPlaying)
					{
						if (GUILayout.Button("Play"))
						{
							_movie.Play();
						}						
					}
					else
					{
						if (GUILayout.Button("Pause"))
						{
							_movie.Pause();
						}
					}
					EditorGUILayout.EndHorizontal();

#if !AVPROWINDOWSMEDIA_UNITYFEATURE_EDITORAUTOREFRESH
					this.Repaint();
#endif
				}
			}
        }
		if (GUI.changed)
		{
			EditorUtility.SetDirty(_movie);
		}

        // If the app isn't running but the media is we may need to manually update it
        if (!Application.isPlaying && _movie.MovieInstance != null)
        {
            _movie.Update();
            AVProWindowsMediaManager.Instance.Update();
            EditorUtility.SetDirty(_movie);
        }
	}