Example #1
0
        protected override void Apply()
        {
            if (AudioSourceComponent != null)
            {
                var v_isDownloading = ExternalResources.IsDownloading(Key);
                if (string.IsNullOrEmpty(Key) || !v_isDownloading ||
                    (_canUnregisterOnDisable && v_isDownloading)) //someone called this request before this external image
                {
                    ExternAudioFile v_callback = !ExternalResources.IsLoaded(Key) ?
                                                 ExternalResources.ReloadClipAsync(Key, ApplyClip) : ExternalResources.LoadClipAsync(Key, ApplyClip);
                    if (v_callback != null)
                    {
                        if (v_callback.IsProcessing())
                        {
                            //Reset image
                            if (Clip != null)
                            {
                                ApplyEmptyClipInAudioSourceComponent();
                            }

                            _canUnregisterOnDisable = false;
                            if (OnRequestDownloadClipCallback != null)
                            {
                                OnRequestDownloadClipCallback.Invoke();
                            }
                        }
                        else
                        {
                            HandleOnAudioLoaded(v_callback);
                        }
                    }
                }
                else
                {
                    if (Clip != null)
                    {
                        ApplyEmptyClipInAudioSourceComponent();
                    }
                    SetDirty();
                }
            }
        }