//long lastGcMemory = 0; void UpdateLoading() { // Finished loading? if (IsAllVideosLoaded()) { // Assign the master and slaves _masterPlayer.BufferedDisplay.SetBufferedDisplayMode(BufferedFrameSelectionMode.ElapsedTimeVsynced); IBufferedDisplay[] slaves = new IBufferedDisplay[_slavePlayers.Length]; for (int i = 0; i < _slavePlayers.Length; i++) { slaves[i] = _slavePlayers[i].BufferedDisplay; } _masterPlayer.BufferedDisplay.SetSlaves(slaves); //System.Threading.Thread.Sleep(1250); // Begin preroll PlayAll(); _state = State.Prerolling; } }
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()); } } } }
/// <inheritdoc/> public virtual void SetBufferedDisplayMode(BufferedFrameSelectionMode mode, IBufferedDisplay master = null) { }
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(); }
public override void SetBufferedDisplayMode(BufferedFrameSelectionMode mode, IBufferedDisplay master = null) { _frameSelectionMode = mode; _masterDisplay = master; UpdateBufferedDisplay(); }