Ejemplo n.º 1
0
        private void OnInspectorGUI_PlayControls(IMediaControl control, IMediaInfo info)
        {
            GUILayout.Space(8.0f);

            // Slider
            EditorGUILayout.BeginHorizontal();
            bool isPlaying = false;

            if (control != null)
            {
                isPlaying = control.IsPlaying();
            }
            float currentTime = 0f;

            if (control != null)
            {
                currentTime = control.GetCurrentTimeMs();
            }

            float durationTime = 0f;

            if (info != null)
            {
                durationTime = info.GetDurationMs();
                if (float.IsNaN(durationTime))
                {
                    durationTime = 0f;
                }
            }
            string timeUsed = Helper.GetTimeString(currentTime / 1000f, true);

            GUILayout.Label(timeUsed, GUILayout.ExpandWidth(false));

            float newTime = GUILayout.HorizontalSlider(currentTime, 0f, durationTime, GUILayout.ExpandWidth(true));

            if (newTime != currentTime)
            {
                control.Seek(newTime);
            }

            string timeTotal = "Infinity";

            if (!float.IsInfinity(durationTime))
            {
                timeTotal = Helper.GetTimeString(durationTime / 1000f, true);
            }

            GUILayout.Label(timeTotal, GUILayout.ExpandWidth(false));

            EditorGUILayout.EndHorizontal();

            // Buttons
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Rewind", GUILayout.ExpandWidth(false)))
            {
                control.Rewind();
            }

            if (!isPlaying)
            {
                GUI.color = Color.green;
                if (GUILayout.Button("Play", GUILayout.ExpandWidth(true)))
                {
                    control.Play();
                }
            }
            else
            {
                GUI.color = Color.yellow;
                if (GUILayout.Button("Pause", GUILayout.ExpandWidth(true)))
                {
                    control.Pause();
                }
            }
            GUI.color = Color.white;
            EditorGUILayout.EndHorizontal();
        }
        void OnGUI()
        {
            if (Event.current.type == EventType.Layout)
            {
                SetGuiPositionFromVideoIndex(_debugOverlayCount++);
            }

            if (_mediaPlayer != null && _mediaPlayer.Info != null)
            {
                IMediaInfo     info            = _mediaPlayer.Info;
                IMediaControl  control         = _mediaPlayer.Control;
                IMediaProducer textureProducer = _mediaPlayer.TextureProducer;

                GUI.depth  = _guiDepth;
                GUI.matrix = Matrix4x4.TRS(new Vector3(m_GuiPositionX, 10f, 0f), Quaternion.identity, new Vector3(_displaySize, _displaySize, 1.0f));

                GUILayout.BeginVertical("box", GUILayout.MaxWidth(s_GuiWidth));
                GUILayout.Label(System.IO.Path.GetFileName(_mediaPlayer.m_VideoPath));
                GUILayout.Label("Dimensions: " + info.GetVideoWidth() + "x" + info.GetVideoHeight() + "@" + info.GetVideoFrameRate().ToString("F2"));
                GUILayout.Label("Time: " + (control.GetCurrentTimeMs() * 0.001f).ToString("F1") + "s / " + (info.GetDurationMs() * 0.001f).ToString("F1") + "s");
                GUILayout.Label("Rate: " + info.GetVideoDisplayRate().ToString("F2") + "Hz");

                if (_mediaPlayer.m_Resample && _mediaPlayer.FrameResampler != null)
                {
                    Resampler resampler = _mediaPlayer.FrameResampler;
                    GUILayout.BeginVertical();
                    GUILayout.Label("Resampler Info:");
                    GUILayout.Label("Resampler timestamp: " + resampler.TextureTimeStamp);
                    GUILayout.Label("Resampler frames dropped: " + resampler.DroppedFrames);
                    GUILayout.Label("Resampler frame displayed timer: " + resampler.FrameDisplayedTimer);
                    GUILayout.EndVertical();
                }

                if (textureProducer != null && textureProducer.GetTexture() != null)
                {
#if REAL_ANDROID
                    // In OES mode we can't display the texture without using a special shader, so just don't display it
                    if (!_optionsAndroid.useFastOesPath)
#endif
                    {
                        // Show texture without and with alpha blending
                        GUILayout.BeginHorizontal();
                        Rect r1 = GUILayoutUtility.GetRect(32f, 32f);
                        GUILayout.Space(8f);
                        Rect      r2         = GUILayoutUtility.GetRect(32f, 32f);
                        Matrix4x4 prevMatrix = GUI.matrix;
                        if (textureProducer.RequiresVerticalFlip())
                        {
                            GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0, r1.y + (r1.height / 2f)));
                        }
                        GUI.DrawTexture(r1, textureProducer.GetTexture(), ScaleMode.ScaleToFit, false);
                        GUI.DrawTexture(r2, textureProducer.GetTexture(), ScaleMode.ScaleToFit, true);
                        GUI.matrix = prevMatrix;
                        GUILayout.FlexibleSpace();
                        GUILayout.EndHorizontal();
                    }
                }

                if (_displayControls)
                {
                    GUILayout.BeginHorizontal();
                    if (control.IsPaused())
                    {
                        if (GUILayout.Button("Play", GUILayout.Width(50)))
                        {
                            control.Play();
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("Pause", GUILayout.Width(50)))
                        {
                            control.Pause();
                        }
                    }

                    float duration = info.GetDurationMs();
                    float time     = control.GetCurrentTimeMs();
                    float newTime  = GUILayout.HorizontalSlider(time, 0f, duration);
                    if (newTime != time)
                    {
                        control.Seek(newTime);
                    }
                    GUILayout.EndHorizontal();
                }

#if AVPROVIDEO_DEBUG_DISPLAY_EVENTS
                // Dirty code to hack in an event monitor
                if (Event.current.type == EventType.Repaint)
                {
                    _mediaPlayer.Events.RemoveListener(OnMediaPlayerEvent);
                    _mediaPlayer.Events.AddListener(OnMediaPlayerEvent);
                    UpdateEventLogs();
                }

                if (_eventLog != null && _eventLog.Count > 0)
                {
                    GUILayout.Label("Recent Events: ");
                    GUILayout.BeginVertical("box");
                    int eventIndex = 0;
                    foreach (string eventString in _eventLog)
                    {
                        GUI.color = Color.white;
                        if (eventIndex == 0)
                        {
                            GUI.color = new Color(1f, 1f, 1f, _eventTimer);
                        }
                        GUILayout.Label(eventString);
                        eventIndex++;
                    }
                    GUILayout.EndVertical();
                    GUI.color = Color.white;
                }
#endif
                GUILayout.EndVertical();
            }
        }
Ejemplo n.º 3
0
        void OnGUI()
        {
            if (m_Info != null && m_DebugGui)
            {
                GUI.depth  = -1;
                GUI.matrix = Matrix4x4.TRS(new Vector3(m_GuiPositionX, 10f, 0f), Quaternion.identity, new Vector3(s_GuiScale, s_GuiScale, 1.0f));

                GUILayout.BeginVertical("box", GUILayout.MaxWidth(s_GuiWidth));
                GUILayout.Label(System.IO.Path.GetFileName(m_VideoPath));
                GUILayout.Label("Dimensions: " + m_Info.GetVideoWidth() + " x " + m_Info.GetVideoHeight());
                GUILayout.Label("Time: " + (m_Control.GetCurrentTimeMs() * 0.001f).ToString("F1") + "s / " + (m_Info.GetDurationMs() * 0.001f).ToString("F1") + "s");
                GUILayout.Label("Rate: " + m_Info.GetVideoPlaybackRate().ToString("F2") + "Hz");

                if (TextureProducer != null && TextureProducer.GetTexture() != null)
                {
                    // Show texture without and with alpha blending
                    GUILayout.BeginHorizontal();
                    Rect r1 = GUILayoutUtility.GetRect(32f, 32f);
                    GUILayout.Space(8f);
                    Rect r2 = GUILayoutUtility.GetRect(32f, 32f);
                    if (TextureProducer.RequiresVerticalFlip())
                    {
                        GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0, r1.y + (r1.height / 2)));
                    }
                    GUI.DrawTexture(r1, TextureProducer.GetTexture(), ScaleMode.ScaleToFit, false);
                    GUI.DrawTexture(r2, TextureProducer.GetTexture(), ScaleMode.ScaleToFit, true);
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();
            }
        }
Ejemplo n.º 4
0
        public void OnGUI()
        {
            if (m_Info != null && m_DebugGui)
            {
                GUI.depth  = s_GuiDepth;
                GUI.matrix = Matrix4x4.TRS(new Vector3(m_GuiPositionX, 10f, 0f), Quaternion.identity, new Vector3(s_GuiScale, s_GuiScale, 1.0f));

                GUILayout.BeginVertical("box", GUILayout.MaxWidth(s_GuiWidth));
                GUILayout.Label(System.IO.Path.GetFileName(m_VideoPath));
                GUILayout.Label("Dimensions: " + m_Info.GetVideoWidth() + "x" + m_Info.GetVideoHeight() + "@" + m_Info.GetVideoFrameRate().ToString("F2"));
                GUILayout.Label("Time: " + (m_Control.GetCurrentTimeMs() * 0.001f).ToString("F1") + "s / " + (m_Info.GetDurationMs() * 0.001f).ToString("F1") + "s");
                GUILayout.Label("Rate: " + m_Info.GetVideoDisplayRate().ToString("F2") + "Hz");

                if (TextureProducer != null && TextureProducer.GetTexture() != null)
                {
                    // Show texture without and with alpha blending
                    GUILayout.BeginHorizontal();
                    Rect r1 = GUILayoutUtility.GetRect(32f, 32f);
                    GUILayout.Space(8f);
                    Rect      r2         = GUILayoutUtility.GetRect(32f, 32f);
                    Matrix4x4 prevMatrix = GUI.matrix;
                    if (TextureProducer.RequiresVerticalFlip())
                    {
                        GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0, r1.y + (r1.height / 2)));
                    }
                    GUI.DrawTexture(r1, TextureProducer.GetTexture(), ScaleMode.ScaleToFit, false);
                    GUI.DrawTexture(r2, TextureProducer.GetTexture(), ScaleMode.ScaleToFit, true);
                    GUI.matrix = prevMatrix;
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }

#if AVPROVIDEO_DEBUG_DISPLAY_EVENTS
                // Dirty code to hack in an event monitor
                if (Event.current.type == EventType.Repaint)
                {
                    this.Events.RemoveListener(OnMediaPlayerEvent);
                    this.Events.AddListener(OnMediaPlayerEvent);
                    UpdateEventLogs();
                }

                if (_eventLog != null && _eventLog.Count > 0)
                {
                    GUILayout.Label("Recent Events: ");
                    GUILayout.BeginVertical("box");
                    int eventIndex = 0;
                    foreach (string eventString in _eventLog)
                    {
                        GUI.color = Color.white;
                        if (eventIndex == 0)
                        {
                            GUI.color = new Color(1f, 1f, 1f, _eventTimer);
                        }
                        GUILayout.Label(eventString);
                        eventIndex++;
                    }
                    GUILayout.EndVertical();
                    GUI.color = Color.white;
                }
#endif
                GUILayout.EndVertical();
            }
        }
Ejemplo n.º 5
0
        void OnGUI()
        {
            if (m_Info != null && m_DebugGui)
            {
                GUI.depth = -1;

                float debugGuiScale = 1.5f;
                GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(debugGuiScale, debugGuiScale, 1.0f));

                GUILayout.BeginArea(new Rect(m_GuiPositionX, 10, (s_GuiWidth - 10), 150));
                GUILayout.BeginVertical("box");
                GUILayout.Label(System.IO.Path.GetFileName(m_VideoPath));
                GUILayout.Label("Dimensions: " + m_Info.GetVideoWidth() + " x " + m_Info.GetVideoHeight());
                GUILayout.Label("Time: " + (m_Control.GetCurrentTimeMs() * 0.001f).ToString("F1") + "s / " + (m_Info.GetDurationMs() * 0.001f).ToString("F1") + "s");
                GUILayout.Label("Rate: " + m_Info.GetVideoPlaybackRate().ToString("F2") + "Hz");
                GUILayout.EndVertical();
                GUILayout.EndArea();
            }
        }
Ejemplo n.º 6
0
		private void OnGUI()
		{
			if (m_Info != null && m_DebugGui)
			{
				GUI.depth = -1000;
				GUI.matrix = Matrix4x4.TRS(new Vector3((float)m_GuiPositionX, 10f, 0f), Quaternion.identity, new Vector3(1.5f, 1.5f, 1f));
				GUILayout.BeginVertical("box", GUILayout.MaxWidth(180f));
				GUILayout.Label(Path.GetFileName(m_VideoPath));
				GUILayout.Label("Dimensions: " + m_Info.GetVideoWidth() + "x" + m_Info.GetVideoHeight() + "@" + m_Info.GetVideoFrameRate().ToString("F2"));
				GUILayout.Label("Time: " + (m_Control.GetCurrentTimeMs() * 0.001f).ToString("F1") + "s / " + (m_Info.GetDurationMs() * 0.001f).ToString("F1") + "s");
				GUILayout.Label("Rate: " + m_Info.GetVideoDisplayRate().ToString("F2") + "Hz");
				if (TextureProducer != null && TextureProducer.GetTexture() != null)
				{
					GUILayout.BeginHorizontal();
					Rect rect = GUILayoutUtility.GetRect(32f, 32f);
					GUILayout.Space(8f);
					Rect rect2 = GUILayoutUtility.GetRect(32f, 32f);
					Matrix4x4 matrix = GUI.matrix;
					if (TextureProducer.RequiresVerticalFlip())
					{
						GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0f, rect.y + rect.height / 2f));
					}
					GUI.DrawTexture(rect, TextureProducer.GetTexture(), ScaleMode.ScaleToFit, alphaBlend: false);
					GUI.DrawTexture(rect2, TextureProducer.GetTexture(), ScaleMode.ScaleToFit, alphaBlend: true);
					GUI.matrix = matrix;
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();
				}
				GUILayout.EndVertical();
			}
		}