IEnumerator DownloadPoems() { int numFiles = 0; List <string> toDownload = new List <string>(); bool isDone = false; GoogleDriveFiles.List().Send().OnDone += list => { foreach (File file in list.Files) { if (!file.Name.Contains("virtualshackrecording")) { continue; } toDownload.Add(file.Id); numFiles++; } for (int i = 0; i < toDownload.Count; i++) { request = GoogleDriveFiles.DownloadAudio(toDownload[i], AudioType.WAV); request.Send().OnDone += file => { SavWav.Save("poem_" + i, file.AudioClip); slider.value = i; }; } isDone = true; }; while (!isDone) { yield return(null); } }
void DownloadFiles() { GoogleDriveFiles.List().Send().OnDone += list => { foreach (File listedFile in list.Files) { if (listedFile.Name.StartsWith("virtualshackrecording")) { GoogleDriveFiles.DownloadAudio(listedFile.Id, AudioType.WAV).Send().OnDone += file => { SavWav.Save("downloaded_" + listedFile.Name, file.AudioClip); }; } } }; }
private async UniTask <byte[]> DownloadFileAsync(UnityGoogleDrive.Data.File fileMeta) { if (useNativeRequests) { if (typeof(TResource) == typeof(AudioClip)) { downloadRequest = GoogleDriveFiles.DownloadAudio(fileMeta.Id, WebUtils.EvaluateAudioTypeFromMime(fileMeta.MimeType)); } else if (typeof(TResource) == typeof(Texture2D)) { downloadRequest = GoogleDriveFiles.DownloadTexture(fileMeta.Id, true); } } else { downloadRequest = new GoogleDriveFiles.DownloadRequest(fileMeta); } await downloadRequest.SendNonGeneric(); if (downloadRequest.IsError || downloadRequest.GetResponseData <UnityGoogleDrive.Data.File>().Content == null) { Debug.LogError($"Failed to download {Path}{usedRepresentation.Extension} resource from Google Drive."); return(null); } if (useNativeRequests) { if (typeof(TResource) == typeof(AudioClip)) { loadedObject = downloadRequest.GetResponseData <UnityGoogleDrive.Data.AudioFile>().AudioClip as TResource; } else if (typeof(TResource) == typeof(Texture2D)) { loadedObject = downloadRequest.GetResponseData <UnityGoogleDrive.Data.TextureFile>().Texture as TResource; } } return(downloadRequest.GetResponseData <UnityGoogleDrive.Data.File>().Content); }
private void DownloadAudio(UnityGoogleDrive.Data.File file) { downloadRequest = GoogleDriveFiles.DownloadAudio(file.Id, AudioType.UNKNOWN); downloadRequest.Send().OnDone += PlayAudio; }