コード例 #1
0
        void UpdatePlaying()
        {
            if (_masterPlayer.Control.IsPlaying())
            {
                if (_logSyncErrors)
                {
                    CheckSync();
                    CheckSmoothness();
                }

                BufferedFramesState state = _masterPlayer.BufferedDisplay.GetBufferedFramesState();
                if (state.bufferedFrameCount < 3)
                {
                    //Debug.LogWarning("FORCE SLEEP");
                    System.Threading.Thread.Sleep(16);
                }
            }
            else
            {
                // Pause slaves
                for (int i = 0; i < _slavePlayers.Length; i++)
                {
                    MediaPlayer slave = _slavePlayers[i];
                    slave.Pause();
                }
            }

            // Finished?
            if (IsPlaybackFinished(_masterPlayer))
            {
                _state = State.Finished;
            }
        }
コード例 #2
0
        string LogSyncState(MediaPlayer player)
        {
            BufferedFramesState state = player.BufferedDisplay.GetBufferedFramesState();
            long   timeStamp          = player.TextureProducer.GetTextureTimeStamp();
            string result             = string.Format("{4} - {2},{3}\t\t{0}-{1}   ({5})", state.minTimeStamp, state.maxTimeStamp, state.bufferedFrameCount, state.freeFrameCount, timeStamp, Time.deltaTime);

            return(result);
        }
コード例 #3
0
        static bool IsPlaybackFinished(MediaPlayer player)
        {
            bool result = false;

            if (player != null && player.Control != null)
            {
                if (player.Control.IsFinished())
                {
                    BufferedFramesState state = player.BufferedDisplay.GetBufferedFramesState();
                    if (state.bufferedFrameCount == 0)
                    {
                        result = true;
                    }
                }
            }
            return(result);
        }
コード例 #4
0
        private void OnInspectorGUI_DevMode_BufferedFrames()
        {
            MediaPlayer mediaPlayer = (this.target) as MediaPlayer;

            if (mediaPlayer.Control != null)
            {
                IBufferedDisplay bufferedDisplay = mediaPlayer.BufferedDisplay;
                if (bufferedDisplay != null)
                {
                    BufferedFramesState state = bufferedDisplay.GetBufferedFramesState();

                    GUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel(_guiTextBufferedFrames);
                    Rect progressRect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight);
                    EditorGUI.ProgressBar(progressRect, _lastBufferedFrameCount, state.bufferedFrameCount.ToString());
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel(_guiTextFreeFrames);
                    progressRect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight);
                    EditorGUI.ProgressBar(progressRect, _lastFreeFrameCount, state.freeFrameCount.ToString());
                    GUILayout.EndHorizontal();

                    _lastBufferedFrameCount = Mathf.MoveTowards(_lastBufferedFrameCount, state.bufferedFrameCount / 12f, Time.deltaTime);
                    _lastFreeFrameCount     = Mathf.MoveTowards(_lastFreeFrameCount, state.freeFrameCount / 12f, Time.deltaTime);

                    //EditorGUILayout.LabelField(_guiTextDisplayTimestamp, new GUIContent(mediaPlayer.TextureProducer.GetTextureTimeStamp().ToString() + " " + (mediaPlayer.TextureProducer.GetTextureTimeStamp() / Helper.SecondsToHNS).ToString() + "s"));
                    //EditorGUILayout.LabelField(_guiTextMinTimestamp, new GUIContent(state.minTimeStamp.ToString() + " " + (state.minTimeStamp / Helper.SecondsToHNS).ToString() + "s"));
                    //EditorGUILayout.LabelField(_guiTextMaxTimestamp, new GUIContent(state.maxTimeStamp.ToString() + " " + (state.maxTimeStamp / Helper.SecondsToHNS).ToString() + "s"));
                    if (GUILayout.Button(_guiTextFlush))
                    {
                        // Seek causes a flush
                        mediaPlayer.Control.Seek(mediaPlayer.Control.GetCurrentTime());
                    }
                }
            }
        }
コード例 #5
0
        void OnGUI()
        {
            // NOTE: These this IMGUI is just temporary until we implement the UI using uGUI
            if (!_showOptions)
            {
                return;
            }
            if (!_mediaPlayer || _mediaPlayer.Control == null)
            {
                return;
            }

            GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(2f, 2f, 1f));

            GUI.backgroundColor = Color.red;
            GUILayout.BeginVertical(GUI.skin.box);
            GUI.backgroundColor = Color.white;

            GUILayout.Label("Duration " + _mediaPlayer.Info.GetDuration() + "s");
            GUILayout.BeginHorizontal();
            GUILayout.Label("States: ");
            GUILayout.Toggle(_mediaPlayer.Control.HasMetaData(), "HasMetaData", GUI.skin.button);
            GUILayout.Toggle(_mediaPlayer.Control.IsPaused(), "Paused", GUI.skin.button);
            GUILayout.Toggle(_mediaPlayer.Control.IsPlaying(), "Playing", GUI.skin.button);
            GUILayout.Toggle(_mediaPlayer.Control.IsBuffering(), "Buffering", GUI.skin.button);
            GUILayout.Toggle(_mediaPlayer.Control.IsSeeking(), "Seeking", GUI.skin.button);
            GUILayout.Toggle(_mediaPlayer.Control.IsFinished(), "Finished", GUI.skin.button);
            GUILayout.EndHorizontal();

            {
                TimeRanges times = _mediaPlayer.Control.GetBufferedTimes();
                if (times != null)
                {
                    GUILayout.Label("Buffered Range " + times.MinTime + " - " + times.MaxTime);
                }
            }
            {
                TimeRanges times = _mediaPlayer.Control.GetSeekableTimes();
                if (times != null)
                {
                    GUILayout.Label("Seek Range " + times.MinTime + " - " + times.MaxTime);
                }
            }


            {
                GUILayout.Label("Video Tracks: " + _mediaPlayer.VideoTracks.GetVideoTracks().Count);

                GUILayout.BeginVertical();

                VideoTrack selectedTrack = null;
                foreach (VideoTrack track in _mediaPlayer.VideoTracks.GetVideoTracks())
                {
                    bool isSelected = (track == _mediaPlayer.VideoTracks.GetActiveVideoTrack());
                    if (isSelected)
                    {
                        GUI.color = Color.green;
                    }
                    if (GUILayout.Button(track.DisplayName, GUILayout.ExpandWidth(false)))
                    {
                        selectedTrack = track;
                    }
                    if (isSelected)
                    {
                        GUI.color = Color.white;
                    }
                }
                GUILayout.EndHorizontal();
                if (selectedTrack != null)
                {
                    _mediaPlayer.VideoTracks.SetActiveVideoTrack(selectedTrack);
                }
            }
            {
                GUILayout.Label("Audio Tracks: " + _mediaPlayer.AudioTracks.GetAudioTracks().Count);

                GUILayout.BeginVertical();

                AudioTrack selectedTrack = null;
                foreach (AudioTrack track in _mediaPlayer.AudioTracks.GetAudioTracks())
                {
                    bool isSelected = (track == _mediaPlayer.AudioTracks.GetActiveAudioTrack());
                    if (isSelected)
                    {
                        GUI.color = Color.green;
                    }
                    if (GUILayout.Button(track.DisplayName, GUILayout.ExpandWidth(false)))
                    {
                        selectedTrack = track;
                    }
                    if (isSelected)
                    {
                        GUI.color = Color.white;
                    }
                }
                GUILayout.EndHorizontal();
                if (selectedTrack != null)
                {
                    _mediaPlayer.AudioTracks.SetActiveAudioTrack(selectedTrack);
                }
            }
            {
                GUILayout.Label("Text Tracks: " + _mediaPlayer.TextTracks.GetTextTracks().Count);

                GUILayout.BeginVertical();

                TextTrack selectedTrack = null;
                foreach (TextTrack track in _mediaPlayer.TextTracks.GetTextTracks())
                {
                    bool isSelected = (track == _mediaPlayer.TextTracks.GetActiveTextTrack());
                    if (isSelected)
                    {
                        GUI.color = Color.green;
                    }
                    if (GUILayout.Button(track.DisplayName, GUILayout.ExpandWidth(false)))
                    {
                        selectedTrack = track;
                    }
                    if (isSelected)
                    {
                        GUI.color = Color.white;
                    }
                }
                GUILayout.EndHorizontal();
                if (selectedTrack != null)
                {
                    _mediaPlayer.TextTracks.SetActiveTextTrack(selectedTrack);
                }
            }
            {
                GUILayout.Label("FPS: " + _mediaPlayer.Info.GetVideoDisplayRate().ToString("F2"));
            }
#if (UNITY_STANDALONE_WIN)
            if (_mediaPlayer.PlatformOptionsWindows.bufferedFrameSelection != BufferedFrameSelectionMode.None)
            {
                IBufferedDisplay bufferedDisplay = _mediaPlayer.BufferedDisplay;
                if (bufferedDisplay != null)
                {
                    BufferedFramesState state = bufferedDisplay.GetBufferedFramesState();
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Buffered Frames: " + state.bufferedFrameCount);
                    GUILayout.HorizontalSlider(state.bufferedFrameCount, 0f, 12f);
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Free Frames: " + state.freeFrameCount);
                    GUILayout.HorizontalSlider(state.freeFrameCount, 0f, 12f);
                    GUILayout.EndHorizontal();
                    GUILayout.Label("Min Timstamp: " + state.minTimeStamp);
                    GUILayout.Label("Max Timstamp: " + state.maxTimeStamp);
                    GUILayout.Label("Display Timstamp: " + _mediaPlayer.TextureProducer.GetTextureTimeStamp());
                }
            }
#endif
            GUILayout.EndVertical();
        }