Example #1
0
        private void Initialise()
        {
            BaseMediaPlayer mediaPlayer = CreatePlatformMediaPlayer();

            if (mediaPlayer != null)
            {
                // Set-up interface
                m_Control = mediaPlayer;
                m_Texture = mediaPlayer;
                m_Info    = mediaPlayer;
                m_Player  = mediaPlayer;
                m_Dispose = mediaPlayer;

                if (!s_GlobalStartup)
                {
#if UNITY_5
                    Debug.Log(string.Format("[AVProVideo] Initialising AVPro Video (script v{0} plugin v{1}) on {2}/{3} (MT {4})", Helper.ScriptVersion, mediaPlayer.GetVersion(), SystemInfo.graphicsDeviceName, SystemInfo.graphicsDeviceVersion, SystemInfo.graphicsMultiThreaded));
#else
                    Debug.Log(string.Format("[AVProVideo] Initialising AVPro Video (script v{0} plugin v{1}) on {2}/{3}", Helper.ScriptVersion, mediaPlayer.GetVersion(), SystemInfo.graphicsDeviceName, SystemInfo.graphicsDeviceVersion));
#endif
#if AVPROVIDEO_BETA_SUPPORT_TIMESCALE
                    Debug.LogWarning("[AVProVideo] TimeScale support used.  This could affect performance when changing Time.timeScale or Time.captureFramerate.  This feature is useful for supporting video capture system that adjust time scale during capturing.");
#endif
                    s_GlobalStartup = true;
                }
            }
        }
Example #2
0
 protected void Initialise()
 {
     BaseMediaPlayer mediaPlayer = CreatePlatformMediaPlayer();
     if (mediaPlayer != null)
     {
         m_Control = mediaPlayer;
         m_Texture = mediaPlayer;
         m_Info = mediaPlayer;
         m_Player = mediaPlayer;
         m_Dispose = mediaPlayer;
     }
 }
		private void OnDestroy()
		{
			CloseVideo();
			if (m_Dispose != null)
			{
				m_Dispose.Dispose();
				m_Dispose = null;
			}
			m_Control = null;
			m_Texture = null;
			m_Info = null;
			m_Player = null;
		}
Example #4
0
        public void OnDestroy()
        {
            CloseVideo();

            if (m_Dispose != null)
            {
                m_Dispose.Dispose();
                m_Dispose = null;
            }
            m_Control = null;
            m_Texture = null;
            m_Info    = null;
            m_Player  = null;

            // TODO: possible bug if MediaPlayers are created and destroyed manually (instantiated), OnApplicationQuit won't be called!
        }
		protected void Initialise()
		{
			BaseMediaPlayer baseMediaPlayer = CreatePlatformMediaPlayer();
			if (baseMediaPlayer != null)
			{
				m_Control = baseMediaPlayer;
				m_Texture = baseMediaPlayer;
				m_Info = baseMediaPlayer;
				m_Player = baseMediaPlayer;
				m_Dispose = baseMediaPlayer;
				if (!s_GlobalStartup)
				{
					Helper.LogInfo(string.Format("Initialising AVPro Video (script v{0} plugin v{1}) on {2}/{3} (MT {4})", "1.5.8", baseMediaPlayer.GetVersion(), SystemInfo.graphicsDeviceName, SystemInfo.graphicsDeviceVersion, SystemInfo.graphicsMultiThreaded));
					s_GlobalStartup = true;
				}
			}
		}
Example #6
0
        void OnDestroy()
        {
            StopRenderCoroutine();

            m_VideoOpened = false;

            if (m_Dispose != null)
            {
                m_Dispose.Dispose();
                m_Dispose = null;
            }
            m_Control = null;
            m_Texture = null;
            m_Info    = null;
            m_Player  = null;

            // TODO: possible bug if MediaPlayers are created and destroyed manually (instantiated), OnApplicationQuit won't be called!
        }
Example #7
0
    void OnDestroy()
    {
        CloseVideo();

        if (m_Dispose != null)
        {
            m_Dispose.Dispose();
            m_Dispose = null;
        }
        m_Control = null;
        m_Texture = null;
        m_Info = null;
        m_Player = null;

        if (m_Resampler != null)
        {
            m_Resampler.Release();
            m_Resampler = null;
        }
    }
Example #8
0
        public void Start()
        {
            BaseMediaPlayer mediaPlayer = CreatePlatformMediaPlayer();

            if (mediaPlayer != null)
            {
                // Set-up interface
                m_Control = mediaPlayer;
                m_Texture = mediaPlayer;
                m_Dispose = mediaPlayer;
                m_Info    = mediaPlayer;
                m_Player  = mediaPlayer;

                if (!s_GlobalStartup)
                {
#if UNITY_5
                    Debug.Log(string.Format("[AVProVideo] Initialising AVPro Video (script v{0} plugin v{1}) on {2}/{3} (MT {4})", Helper.ScriptVersion, mediaPlayer.GetVersion(), SystemInfo.graphicsDeviceName, SystemInfo.graphicsDeviceVersion, SystemInfo.graphicsMultiThreaded));
#else
                    Debug.Log(string.Format("[AVProVideo] Initialising AVPro Video (script v{0} plugin v{1}) on {2}/{3}", Helper.ScriptVersion, mediaPlayer.GetVersion(), SystemInfo.graphicsDeviceName, SystemInfo.graphicsDeviceVersion));
#endif
                    s_GlobalStartup = true;
                }

                // Open?
                if (m_AutoOpen)
                {
                    OpenVideoFromFile();
                }

                SetPlaybackOptions();

                if (m_Control != null)
                {
                    StartCoroutine("FinalRenderCapture");
                }
            }
        }
Example #9
0
        public override void OnInspectorGUI()
        {
            PlaylistMediaPlayer media = (this.target) as PlaylistMediaPlayer;

            serializedObject.Update();

            if (media == null || _propPlayerA == null)
            {
                return;
            }

            EditorGUILayout.PropertyField(_propPlayerA);
            EditorGUILayout.PropertyField(_propPlayerB);
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            GUILayout.Label("Playlist", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(_propPlaylistAutoProgress, new GUIContent("Auto Progress"));
            EditorGUILayout.PropertyField(_propPlaylistLoopMode, new GUIContent("Loop Mode"));
            EditorGUILayout.PropertyField(_propPlaylist);
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            GUILayout.Label("Transition", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(_propNextTransition, new GUIContent("Next"));
            EditorGUILayout.PropertyField(_propTransitionEasing, new GUIContent("Easing"));
            EditorGUILayout.PropertyField(_propTransitionDuration, new GUIContent("Duration"));
            EditorGUILayout.PropertyField(_propPausePreviousOnTransition, new GUIContent("Pause Previous"));
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            if (Application.isPlaying)
            {
                IMediaProducer textureSource = media.TextureProducer;

                Texture texture = null;
                if (textureSource != null)
                {
                    texture = textureSource.GetTexture();
                }
                if (texture == null)
                {
                    texture = EditorGUIUtility.whiteTexture;
                }

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

                // Reserve rectangle for texture
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                Rect textureRect;
                Rect alphaRect = new Rect(0f, 0f, 1f, 1f);
                if (texture != EditorGUIUtility.whiteTexture)
                {
                    textureRect = GUILayoutUtility.GetRect(Screen.width / 2, Screen.width / 2, (Screen.width / 2) / ratio, (Screen.width / 2) / ratio);
                }
                else
                {
                    textureRect = GUILayoutUtility.GetRect(1920f / 40f, 1080f / 40f);
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                string rateText   = "0";
                string playerText = string.Empty;
                if (media.Info != null)
                {
                    rateText   = media.Info.GetVideoDisplayRate().ToString("F2");
                    playerText = media.Info.GetPlayerDescription();
                }

                EditorGUILayout.LabelField("Display Rate", rateText);
                EditorGUILayout.LabelField("Using", playerText);

                // Draw the texture
                Matrix4x4 prevMatrix = GUI.matrix;
                if (textureSource != null && textureSource.RequiresVerticalFlip())
                {
                    GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0, textureRect.y + (textureRect.height / 2)));
                }

                if (!GUI.enabled)
                {
                    GUI.color = Color.grey;
                    GUI.DrawTexture(textureRect, texture, ScaleMode.ScaleToFit, false);
                    GUI.color = Color.white;
                }
                else
                {
                    {
                        GUI.DrawTexture(textureRect, texture, ScaleMode.ScaleToFit, false);
                        EditorGUI.DrawTextureAlpha(alphaRect, texture, ScaleMode.ScaleToFit);
                    }
                }
                GUI.matrix = prevMatrix;
            }

            EditorGUI.BeginDisabledGroup(!(media.Control != null && media.Control.CanPlay() && media.isActiveAndEnabled && !EditorApplication.isPaused));
            OnInspectorGUI_PlayControls(media.Control, media.Info);
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            EditorGUI.BeginDisabledGroup(!Application.isPlaying);

            GUILayout.Label("Current Item: " + media.PlaylistIndex + " / " + Mathf.Max(0, media.Playlist.Items.Count - 1));

            GUILayout.BeginHorizontal();
            EditorGUI.BeginDisabledGroup(!media.CanJumpToItem(media.PlaylistIndex - 1));
            if (GUILayout.Button("Prev"))
            {
                media.PrevItem();
            }
            EditorGUI.EndDisabledGroup();
            EditorGUI.BeginDisabledGroup(!media.CanJumpToItem(media.PlaylistIndex + 1));
            if (GUILayout.Button("Next"))
            {
                media.NextItem();
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();

            serializedObject.ApplyModifiedProperties();
        }
        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();
            }
        }
Example #11
0
        private void OnInspectorGUI_VideoPreview(IMediaProducer textureSource)
        {
            Texture texture = null;

            if (textureSource != null)
            {
                texture = textureSource.GetTexture();
            }
            if (texture == null)
            {
                texture = EditorGUIUtility.whiteTexture;
            }

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

            // Reserve rectangle for texture
            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();

            // Dimensions
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label(string.Format("{0}x{1}", texture.width, texture.height));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

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

            // Draw the texture
            Matrix4x4 prevMatrix = GUI.matrix;

            if (textureSource != null && textureSource.RequiresVerticalFlip())
            {
                GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0, textureRect.y + (textureRect.height / 2)));
            }
            if (!_showAlpha)
            {
                if (!GUI.enabled)
                {
                    GUI.color = Color.grey;
                }
                GUI.DrawTexture(textureRect, texture, ScaleMode.ScaleToFit, true);
                GUI.color = Color.white;
            }
            else
            {
                EditorGUI.DrawTextureAlpha(textureRect, texture, ScaleMode.ScaleToFit);
            }
            GUI.matrix = prevMatrix;

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