private void OnInspectorGUI_MediaInfo() { MediaPlayer media = (this.target) as MediaPlayer; IMediaInfo info = media.Info; IMediaControl control = media.Control; ITextTracks textTracks = media.TextTracks; IAudioTracks audioTracks = media.AudioTracks; IVideoTracks videoTracks = media.VideoTracks; if (info != null) { if (!info.HasVideo() && !info.HasAudio()) // && !info.HasText()) { GUILayout.Label("No media loaded"); } else { if (info.HasVideo()) { GUILayout.BeginHorizontal(); { string dimensionText = string.Format("{0}x{1}@{2:0.##}", info.GetVideoWidth(), info.GetVideoHeight(), info.GetVideoFrameRate()); GUILayout.Label(dimensionText); GUILayout.FlexibleSpace(); string rateText = "0.00"; if (media.Info != null) { rateText = media.Info.GetVideoDisplayRate().ToString("F2"); } GUILayout.Label(rateText + "FPS"); } GUILayout.EndHorizontal(); EditorGUILayout.Space(); } if (info.HasVideo()) { VideoTracks tracks = videoTracks.GetVideoTracks(); if (tracks.Count > 0) { GUILayout.Label("Video Tracks: " + tracks.Count); foreach (VideoTrack track in tracks) { bool isActiveTrack = (track == videoTracks.GetActiveVideoTrack()); GUI.color = isActiveTrack?Color.green:Color.white; { if (GUILayout.Button(track.DisplayName)) { if (isActiveTrack) { videoTracks.SetActiveVideoTrack(null); } else { videoTracks.SetActiveVideoTrack(track); } } } } GUI.color = Color.white; EditorGUILayout.Space(); } } if (info.HasAudio()) { AudioTracks tracks = audioTracks.GetAudioTracks(); if (tracks.Count > 0) { GUILayout.Label("Audio Tracks: " + tracks.Count); foreach (AudioTrack track in tracks) { bool isActiveTrack = (track == audioTracks.GetActiveAudioTrack()); GUI.color = isActiveTrack?Color.green:Color.white; { if (GUILayout.Button(track.DisplayName)) { if (isActiveTrack) { audioTracks.SetActiveAudioTrack(null); } else { audioTracks.SetActiveAudioTrack(track); } } } } GUI.color = Color.white; /*int channelCount = control.GetAudioChannelCount(); * if (channelCount > 0) * { * GUILayout.Label("Audio Channels: " + channelCount); * AudioChannelMaskFlags audioChannels = control.GetAudioChannelMask(); * GUILayout.Label("(" + audioChannels + ")", EditorHelper.IMGUI.GetWordWrappedTextAreaStyle()); * }*/ EditorGUILayout.Space(); } } { TextTracks tracks = textTracks.GetTextTracks(); if (tracks.Count > 0) { GUILayout.Label("Text Tracks: " + tracks.Count); foreach (TextTrack track in tracks) { bool isActiveTrack = (track == textTracks.GetActiveTextTrack()); GUI.color = isActiveTrack?Color.green:Color.white; { if (GUILayout.Button(track.DisplayName)) { if (isActiveTrack) { textTracks.SetActiveTextTrack(null); } else { textTracks.SetActiveTextTrack(track); } } } } GUI.color = Color.white; if (textTracks.GetActiveTextTrack() != null) { string text = string.Empty; if (textTracks.GetCurrentTextCue() != null) { text = textTracks.GetCurrentTextCue().Text; // Clip the text if it is too long if (text.Length >= 96) { text = string.Format("{0}...({1} chars)", text.Substring(0, 96), text.Length); } } GUILayout.Label(text, EditorHelper.IMGUI.GetWordWrappedTextAreaStyle(), GUILayout.Height(48f)); } EditorGUILayout.Space(); } } } } else { GUILayout.Label("No media loaded"); } }