private void BeginNextThumbnail(int index) { EditorApplication.update -= UpdateGenerateThumbnail; _mediaFrame = -1; _timeoutTimer = 0f; if (_thumbnailPlayer != null) { if (index < this.targets.Length) { _targetIndex = index; MediaReference media = (this.targets[_targetIndex]) as MediaReference; string path = media.MediaPath.GetResolvedFullPath(); bool openedMedia = false; if (!string.IsNullOrEmpty(path)) { if (_thumbnailPlayer.OpenMedia(path, 0, string.Empty, media.Hints, 0, false)) { openedMedia = true; EditorApplication.update += UpdateGenerateThumbnail; } } if (!openedMedia) { // If the media failed to open, continue to the next one BeginNextThumbnail(_targetIndex + 1); } } else { EndGenerateThumbnails(true); } } }
static MediaReferenceTest() { ConstructorArgumentValidationTestScenarios .RemoveAllScenarios() .AddScenario(() => new ConstructorArgumentValidationTestScenario <MediaReference> { Name = "constructor should throw ArgumentNullException when parameter 'url' is null scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <MediaReference>(); var result = new MediaReference( null, referenceObject.MediaReferenceKind, referenceObject.Name); return(result); }, ExpectedExceptionType = typeof(ArgumentNullException), ExpectedExceptionMessageContains = new[] { "url", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <MediaReference> { Name = "constructor should throw ArgumentException when parameter 'url' is white space scenario", ConstructionFunc = () => { var referenceObject = A.Dummy <MediaReference>(); var result = new MediaReference( Invariant($" {Environment.NewLine} "), referenceObject.MediaReferenceKind, referenceObject.Name); return(result); }, ExpectedExceptionType = typeof(ArgumentException), ExpectedExceptionMessageContains = new[] { "url", "white space", }, }) .AddScenario(() => new ConstructorArgumentValidationTestScenario <MediaReference> { Name = "constructor should throw ArgumentOutOfRangeException when parameter 'mediaReferenceKind' is Unknown", ConstructionFunc = () => { var referenceObject = A.Dummy <MediaReference>(); var result = new MediaReference( referenceObject.Url, MediaReferenceKind.Unknown, referenceObject.Name); return(result); }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), ExpectedExceptionMessageContains = new[] { "mediaReferenceKind", "Unknown", }, }); }
/// <summary> /// Using the ImageVault Sdk Client, fetch the Media for the reference /// </summary> /// <param name="mediaReference">The reference to the media.</param> /// <returns></returns> private static string GetImageUrl(MediaReference mediaReference) { var media = ClientFactory.GetSdkClient() .Load <Media>(mediaReference, new ViewContext(), new PropertyMediaSettings()) .FirstOrDefault(); if (media == null) { return(null); } return(UriUtil.Combine(SiteDefinition.Current.SiteUrl.ToString(), media.Url)); }
public override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height) { MediaReference media = this.target as MediaReference; if (media) { bool isLinear = false; #if !UNITY_2018_1_OR_NEWER // NOTE: These older versions of Unity don't handle sRGB in the editor correctly so a workaround is to create texture as linear isLinear = true; #endif Texture2D result = new Texture2D(width, height, TextureFormat.RGBA32, true, isLinear); if (!media.GetPreview(result)) { DestroyImmediate(result); result = null; } return(result); } return(null); }
private void ShowProgress() { // Show cancellable progress float t = (float)_targetIndex / (float)this.targets.Length; t = 0.25f + t * 0.75f; MediaReference media = (this.targets[_targetIndex]) as MediaReference; #if UNITY_2020_1_OR_NEWER if (_progressId < 0) { //Progress.RegisterCancelCallback(_progressId...) _progressId = Progress.Start("[AVProVideo] Generating Thumbnails...", null, Progress.Options.Managed); } Progress.Report(_progressId, t, media.MediaPath.Path); #else if (EditorUtility.DisplayCancelableProgressBar("[AVProVideo] Generating Thumbnails...", media.MediaPath.Path, t)) { EndGenerateThumbnails(false); } #endif }
private void OnInspectorGUI_Player(MediaPlayer mediaPlayer, ITextureProducer textureSource) { EditorGUILayout.BeginVertical(GUI.skin.box); Rect titleRect = Rect.zero; // Display filename as title of preview { string mediaFileName = string.Empty; if ((MediaSource)_propMediaSource.enumValueIndex == MediaSource.Path) { mediaFileName = mediaPlayer.MediaPath.Path; } else if ((MediaSource)_propMediaSource.enumValueIndex == MediaSource.Reference) { if (_propMediaReference.objectReferenceValue != null) { mediaFileName = ((MediaReference)_propMediaReference.objectReferenceValue).GetCurrentPlatformMediaReference().MediaPath.Path; } } // Display the file name, cropping if necessary if (!string.IsNullOrEmpty(mediaFileName) && (0 > mediaFileName.IndexOfAny(System.IO.Path.GetInvalidPathChars()))) { string text = System.IO.Path.GetFileName(mediaFileName); titleRect = GUILayoutUtility.GetRect(GUIContent.none, GUI.skin.label); // Draw background GUI.Box(titleRect, GUIContent.none, EditorStyles.toolbarButton); DrawCenterCroppedLabel(titleRect, text); } } // Toggle preview if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.isMouse) { if (titleRect.Contains(Event.current.mousePosition)) { _queuedToggleShowPreview = true; } } if (_showPreview) { Texture texture = EditorGUIUtility.whiteTexture; float textureRatio = 16f / 9f; if (_lastTextureRatio > 0f) { textureRatio = _lastTextureRatio; } if (textureSource != null && textureSource.GetTexture() != null) { texture = textureSource.GetTexture(); if (_previewTexture) { texture = _previewTexture; } _lastTextureRatio = textureRatio = (float)texture.width / (float)texture.height; } // Reserve rectangle for texture //GUILayout.BeginHorizontal(GUILayout.MaxHeight(Screen.height / 2f), GUILayout.ExpandHeight(true)); //GUILayout.FlexibleSpace(); Rect textureRect; //textureRect = GUILayoutUtility.GetRect(256f, 256f); if (texture != EditorGUIUtility.whiteTexture) { if (_showAlpha) { float rectRatio = textureRatio * 2f; rectRatio = Mathf.Max(1f, rectRatio); textureRect = GUILayoutUtility.GetAspectRect(rectRatio, GUILayout.ExpandWidth(true)); } else { //textureRatio *= 2f; float rectRatio = Mathf.Max(1f, textureRatio); textureRect = GUILayoutUtility.GetAspectRect(rectRatio, GUILayout.ExpandWidth(true), GUILayout.Height(256f)); /*GUIStyle style = new GUIStyle(GUI.skin.box); * style.stretchHeight = true; * style.stretchWidth = true; * style.fixedWidth = 0; * style.fixedHeight = 0; * textureRect = GUILayoutUtility.GetRect(Screen.width, Screen.width, 128f, Screen.height / 1.2f, style);*/ } } else { float rectRatio = Mathf.Max(1f, textureRatio); textureRect = GUILayoutUtility.GetAspectRect(rectRatio, GUILayout.ExpandWidth(true), GUILayout.Height(256f)); } if (textureRect.height > (Screen.height / 2f)) { //textureRect.height = Screen.height / 2f; } //Debug.Log(textureRect.height + " " + Screen.height); //GUILayout.FlexibleSpace(); //GUILayout.EndHorizontal(); // Pause / Play toggle on mouse click if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.isMouse) { if (textureRect.Contains(Event.current.mousePosition)) { if (mediaPlayer.Control != null) { if (mediaPlayer.Control.IsPaused()) { mediaPlayer.Play(); } else { mediaPlayer.Pause(); } } } } if (Event.current.type == EventType.Repaint) { GUI.color = Color.gray; EditorGUI.DrawTextureTransparent(textureRect, Texture2D.blackTexture, ScaleMode.StretchToFill); GUI.color = Color.white; //EditorGUI.DrawTextureAlpha(textureRect, Texture2D.whiteTexture, ScaleMode.ScaleToFit); //GUI.color = Color.black; //GUI.DrawTexture(textureRect, texture, ScaleMode.StretchToFill, false); //GUI.color = Color.white; // Draw the texture Matrix4x4 prevMatrix = GUI.matrix; if (textureSource != null && textureSource.RequiresVerticalFlip()) { // GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0f, textureRect.y + (textureRect.height / 2f))); } if (!GUI.enabled) { //GUI.color = Color.black; //GUI.DrawTexture(textureRect, texture, ScaleMode.ScaleToFit, false); //GUI.color = Color.white; } else { if (_showPreview && texture != EditorGUIUtility.whiteTexture) { RenderPreview(mediaPlayer); } if (!_showAlpha) { if (texture != EditorGUIUtility.whiteTexture) { // TODO: In Linear mode, this displays the texture too bright, but GUI.DrawTexture displays it correctly //GL.sRGBWrite = true; //GUI.DrawTexture(textureRect, rt, ScaleMode.ScaleToFit, false); if (_previewTexture) { EditorGUI.DrawPreviewTexture(textureRect, _previewTexture, _materialIMGUI, ScaleMode.ScaleToFit); } //EditorGUI.DrawTextureTransparent(textureRect, rt, ScaleMode.ScaleToFit); //VideoRender.DrawTexture(textureRect, rt, ScaleMode.ScaleToFit, AlphaPacking.None, _materialPreview); //GL.sRGBWrite = false; } else { // Fill with black //GUI.color = Color.black; //GUI.DrawTexture(textureRect, texture, ScaleMode.StretchToFill, false); //GUI.color = Color.white; } } else { textureRect.width /= 2f; //GUI.DrawTexture(textureRect, rt, ScaleMode.ScaleToFit, false); //GL.sRGBWrite = true; //VideoRender.DrawTexture(textureRect, rt, ScaleMode.ScaleToFit, AlphaPacking.None, _materialIMGUI); //GL.sRGBWrite = false; textureRect.x += textureRect.width; //EditorGUI.DrawTextureAlpha(textureRect, texture, ScaleMode.ScaleToFit); } } GUI.matrix = prevMatrix; } } IMediaInfo info = mediaPlayer.Info; IMediaControl control = mediaPlayer.Control; bool showBrowseMenu = false; if (true) { bool isPlaying = false; if (control != null) { isPlaying = control.IsPlaying(); } // Slider layout EditorGUILayout.BeginHorizontal(GUILayout.Height(EditorGUIUtility.singleLineHeight / 2f)); Rect sliderRect = GUILayoutUtility.GetRect(GUIContent.none, GUI.skin.horizontalSlider, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); EditorGUILayout.EndHorizontal(); float currentTime = 0f; float durationTime = 0.001f; if (control != null) { currentTime = (float)control.GetCurrentTime(); durationTime = (float)info.GetDuration(); if (float.IsNaN(durationTime)) { durationTime = 0f; } } TimeRange timelineRange = new TimeRange(0.0, 0.001); // A tiny default duration to prevent divide by zero's if (info != null) { timelineRange = Helper.GetTimelineRange(info.GetDuration(), control.GetSeekableTimes()); } // Slider { // Draw buffering if (control != null && timelineRange.Duration > 0.0 && Event.current.type == EventType.Repaint) { GUI.color = new Color(0f, 1f, 0f, 0.25f); TimeRanges times = control.GetBufferedTimes(); if (timelineRange.Duration > 0.0) { for (int i = 0; i < times.Count; i++) { Rect bufferedRect = sliderRect; float startT = Mathf.Clamp01((float)((times[i].StartTime - timelineRange.StartTime) / timelineRange.Duration)); float endT = Mathf.Clamp01((float)((times[i].EndTime - timelineRange.StartTime) / timelineRange.Duration)); bufferedRect.xMin = sliderRect.xMin + sliderRect.width * startT; bufferedRect.xMax = sliderRect.xMin + sliderRect.width * endT; bufferedRect.yMin += sliderRect.height * 0.5f; GUI.DrawTexture(bufferedRect, Texture2D.whiteTexture); } } GUI.color = Color.white; } // Timeline slider { float newTime = GUI.HorizontalSlider(sliderRect, currentTime, (float)timelineRange.StartTime, (float)timelineRange.EndTime); if (newTime != currentTime) { if (control != null) { // NOTE: For unknown reasons the seeks here behave differently to the MediaPlayerUI demo // When scrubbing (especially with NotchLC) while the video is playing, the frames will not update and a Stalled state will be shown, // but using the MediaPlayerUI the same scrubbing will updates the frames. Perhaps it's just an execution order issue control.Seek(newTime); } } } } EditorGUILayout.BeginHorizontal(); string timeTotal = "∞"; if (!float.IsInfinity(durationTime)) { timeTotal = Helper.GetTimeString(durationTime, false); } string timeUsed = Helper.GetTimeString(currentTime - (float)timelineRange.StartTime, false); GUILayout.Label(timeUsed, GUILayout.ExpandWidth(false)); //GUILayout.Label("/", GUILayout.ExpandWidth(false)); GUILayout.FlexibleSpace(); GUILayout.Label(timeTotal, GUILayout.ExpandWidth(false)); EditorGUILayout.EndHorizontal(); // In non-pro we need to make these 3 icon content black as the buttons are light // and the icons are white by default if (!EditorGUIUtility.isProSkin) { GUI.contentColor = Color.black; } EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); // Play/Pause { float maxHeight = GUI.skin.button.CalcHeight(_iconSceneViewAudio, 0f); if (!isPlaying) { GUI.color = Color.green; if (GUILayout.Button(_iconPlayButton, GUILayout.ExpandWidth(false), GUILayout.Height(maxHeight))) { if (control != null) { control.Play(); } else { if (mediaPlayer.MediaSource == MediaSource.Path) { mediaPlayer.OpenMedia(mediaPlayer.MediaPath.PathType, mediaPlayer.MediaPath.Path, true); } else if (mediaPlayer.MediaSource == MediaSource.Reference) { mediaPlayer.OpenMedia(mediaPlayer.MediaReference, true); } } } } else { GUI.color = Color.yellow; if (GUILayout.Button(_iconPauseButton, GUILayout.ExpandWidth(false), GUILayout.Height(maxHeight))) { if (control != null) { control.Pause(); } } } GUI.color = Color.white; } // Looping { if (!_propLoop.boolValue) { GUI.color = Color.grey; } float maxHeight = GUI.skin.button.CalcHeight(_iconSceneViewAudio, 0f); //GUIContent icon = new GUIContent("∞"); if (GUILayout.Button(_iconRotateTool, GUILayout.Height(maxHeight))) { if (control != null) { control.SetLooping(!_propLoop.boolValue); } _propLoop.boolValue = !_propLoop.boolValue; } GUI.color = Color.white; } // Mute & Volume EditorGUI.BeginDisabledGroup(UnityEditor.EditorUtility.audioMasterMute); { if (_propMuted.boolValue) { GUI.color = Color.gray; } float maxWidth = _iconPlayButton.image.width; //if (GUILayout.Button("Muted", GUILayout.ExpandWidth(false), GUILayout.Height(EditorGUIUtility.singleLineHeight))) //string iconName = "d_AudioListener Icon"; // Unity 2019+ if (GUILayout.Button(_iconSceneViewAudio)) //, GUILayout.Width(maxWidth), GUILayout.Height(EditorGUIUtility.singleLineHeight), GUILayout.ExpandHeight(false))) { if (control != null) { control.MuteAudio(!_propMuted.boolValue); } _propMuted.boolValue = !_propMuted.boolValue; } GUI.color = Color.white; } if (!_propMuted.boolValue) { EditorGUI.BeginChangeCheck(); float newVolume = GUILayout.HorizontalSlider(_propVolume.floatValue, 0f, 1f, GUILayout.ExpandWidth(true), GUILayout.MinWidth(64f)); if (EditorGUI.EndChangeCheck()) { if (control != null) { control.SetVolume(newVolume); } _propVolume.floatValue = newVolume; } } EditorGUI.EndDisabledGroup(); GUI.contentColor = Color.white; GUILayout.FlexibleSpace(); if (Event.current.commandName == "ObjectSelectorClosed" && EditorGUIUtility.GetObjectPickerControlID() == 200) { _queuedLoadMediaRef = (MediaReference)EditorGUIUtility.GetObjectPickerObject(); } if (GUILayout.Button(_iconProject, GUILayout.ExpandWidth(false))) { showBrowseMenu = true; } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); if (showBrowseMenu) { RecentMenu.Create(_propMediaPath, _propMediaSource, MediaFileExtensions, true, 200); } if (_queuedLoadMediaRef && Event.current.type == EventType.Repaint) { //MediaPlayer mediaPlayer = (MediaPlayer)_propMediaPath.serializedObject.targetObject; if (mediaPlayer) { mediaPlayer.OpenMedia(_queuedLoadMediaRef, true); _queuedLoadMediaRef = null; } } if (_queuedToggleShowPreview) { _showPreview = !_showPreview; _queuedToggleShowPreview = false; this.Repaint(); } }
private void OnInspectorGUI_Source() { // Display the file name and buttons to load new files MediaPlayer mediaPlayer = (this.target) as MediaPlayer; EditorGUILayout.PropertyField(_propMediaSource); if (MediaSource.Reference == (MediaSource)_propMediaSource.enumValueIndex) { EditorGUILayout.PropertyField(_propMediaReference); } EditorGUILayout.BeginVertical(GUI.skin.box); if (MediaSource.Reference != (MediaSource)_propMediaSource.enumValueIndex) { OnInspectorGUI_CopyableFilename(mediaPlayer.MediaPath.Path); EditorGUILayout.PropertyField(_propMediaPath); } //if (!Application.isPlaying) { GUI.color = Color.white; GUILayout.BeginHorizontal(); if (_allowDeveloperMode) { if (GUILayout.Button("Rewind")) { mediaPlayer.Rewind(true); } if (GUILayout.Button("Preroll")) { mediaPlayer.RewindPrerollPause(); } if (GUILayout.Button("End")) { mediaPlayer.Control.Seek(mediaPlayer.Info.GetDuration()); } } if (GUILayout.Button("Close")) { mediaPlayer.CloseMedia(); } if (GUILayout.Button("Load")) { if (mediaPlayer.MediaSource == MediaSource.Path) { mediaPlayer.OpenMedia(mediaPlayer.MediaPath.PathType, mediaPlayer.MediaPath.Path, mediaPlayer.AutoStart); } else if (mediaPlayer.MediaSource == MediaSource.Reference) { mediaPlayer.OpenMedia(mediaPlayer.MediaReference, mediaPlayer.AutoStart); } } /*if (media.Control != null) * { * if (GUILayout.Button("Unload")) * { * media.CloseVideo(); * } * }*/ if (EditorGUIUtility.GetObjectPickerControlID() == 100 && Event.current.commandName == "ObjectSelectorClosed") { MediaReference mediaRef = (MediaReference)EditorGUIUtility.GetObjectPickerObject(); if (mediaRef) { _propMediaSource.enumValueIndex = (int)MediaSource.Reference; _propMediaReference.objectReferenceValue = mediaRef; } } GUI.color = Color.green; MediaPathDrawer.ShowBrowseButtonIcon(_propMediaPath, _propMediaSource); GUI.color = Color.white; GUILayout.EndHorizontal(); //MediaPath mediaPath = new MediaPath(_propMediaPath.FindPropertyRelative("_path").stringValue, (MediaPathType)_propMediaPath.FindPropertyRelative("_pathType").enumValueIndex); //ShowFileWarningMessages((MediaSource)_propMediaSource.enumValueIndex, mediaPath, (MediaReference)_propMediaReference.objectReferenceValue, mediaPlayer.AutoOpen, Platform.Unknown); GUI.color = Color.white; } if (MediaSource.Reference != (MediaSource)_propMediaSource.enumValueIndex) { GUILayout.Label("Fallback Media Hints", EditorStyles.boldLabel); EditorGUILayout.PropertyField(_propFallbackMediaHints); } EditorGUILayout.EndVertical(); }
internal static void ShowFileWarningMessages(string filePath, MediaPathType fileLocation, MediaReference mediaReference, MediaSource mediaSource, bool isAutoOpen, Platform platform) { MediaPath mediaPath = null; if (mediaSource == MediaSource.Path) { mediaPath = new MediaPath(filePath, fileLocation); } else if (mediaSource == MediaSource.Reference) { if (mediaReference != null) { mediaPath = mediaReference.GetCurrentPlatformMediaReference().MediaPath; } } ShowFileWarningMessages(mediaPath, isAutoOpen, platform); }
internal static void ShowFileWarningMessages(MediaSource mediaSource, MediaPath mediaPath, MediaReference mediaReference, bool isAutoOpen, Platform platform) { MediaPath result = null; if (mediaSource == MediaSource.Path) { if (mediaPath != null) { result = mediaPath; } } else if (mediaSource == MediaSource.Reference) { if (mediaReference != null) { result = mediaReference.GetCurrentPlatformMediaReference().MediaPath; } } ShowFileWarningMessages(result, isAutoOpen, platform); }
public bool OpenMedia(MediaReference mediaReference, bool autoPlay = true) { return(_mediaPlayer.OpenMedia(mediaReference, autoPlay)); }
private void UpdateGenerateThumbnail() { if (Time.renderedFrameCount == _lastFrame) { // In at least Unity 5.6 we have to force refresh of the UI otherwise the render thread doesn't run to update the textures this.Repaint(); UnityEditorInternal.InternalEditorUtility.RepaintAllViews(); return; } // Wait for a frame to be rendered Debug.Assert(_thumbnailPlayer != null); if (_thumbnailPlayer != null) { _timeoutTimer += Time.unscaledDeltaTime; bool nextVideo = false; _thumbnailPlayer.Update(); _thumbnailPlayer.Render(); if (_mediaFrame < 0 && _thumbnailPlayer.CanPlay()) { _thumbnailPlayer.MuteAudio(true); _thumbnailPlayer.Play(); _thumbnailPlayer.Seek(_thumbnailPlayer.GetDuration() * _thumbnailTime); _mediaFrame = _thumbnailPlayer.GetTextureFrameCount(); } if (_thumbnailPlayer.GetTexture() != null) { if (_mediaFrame != _thumbnailPlayer.GetTextureFrameCount() && _thumbnailPlayer.GetTextureFrameCount() > 3) { bool prevSRGB = GL.sRGBWrite; GL.sRGBWrite = false; RenderTexture rt2 = null; // TODO: move this all into VideoRender as a resolve method { Material materialResolve = new Material(Shader.Find(VideoRender.Shader_Resolve)); VideoRender.SetupVerticalFlipMaterial(materialResolve, _thumbnailPlayer.RequiresVerticalFlip()); VideoRender.SetupAlphaPackedMaterial(materialResolve, _thumbnailPlayer.GetTextureAlphaPacking()); VideoRender.SetupGammaMaterial(materialResolve, !_thumbnailPlayer.PlayerSupportsLinearColorSpace()); RenderTexture prev = RenderTexture.active; // Scale to fit and downsample rt2 = RenderTexture.GetTemporary(128, 128, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB); RenderTexture.active = rt2; GL.Clear(false, true, new Color(0f, 0f, 0f, 0f)); ScaleMode scaleMode = ScaleMode.ScaleToFit; if (_zoomToFill) { scaleMode = ScaleMode.ScaleAndCrop; } VideoRender.DrawTexture(new Rect(0f, 0f, 128f, 128f), _thumbnailPlayer.GetTexture(), scaleMode, _thumbnailPlayer.GetTextureAlphaPacking(), materialResolve); RenderTexture.active = prev; Material.DestroyImmediate(materialResolve); materialResolve = null; } Texture2D readTexture = new Texture2D(128, 128, TextureFormat.RGBA32, true, false); Helper.GetReadableTexture(rt2, readTexture); MediaReference mediaRef = (this.targets[_targetIndex]) as MediaReference; mediaRef.GeneratePreview(readTexture); DestroyImmediate(readTexture); readTexture = null; RenderTexture.ReleaseTemporary(rt2); GL.sRGBWrite = prevSRGB; nextVideo = true; Debug.Log("Thumbnail Written"); } } if (!nextVideo) { // If there is an error or it times out, then skip this media if (_timeoutTimer > 10f || _thumbnailPlayer.GetLastError() != ErrorCode.None) { MediaReference mediaRef = (this.targets[_targetIndex]) as MediaReference; mediaRef.GeneratePreview(null); nextVideo = true; } } if (nextVideo) { BeginNextThumbnail(_targetIndex + 1); } } _lastFrame = Time.renderedFrameCount; }