private bool UploadVideos(ref bool atLeastOneSuccess) { var success = true; try { var files = SelectFiles(); VimeoApi vimeoApi = new VimeoApi(Token); foreach (var file in files) { try { XDocument xdoc = XDocument.Load(file.Path); foreach (var xvideo in xdoc.XPathSelectElements("/Videos/Video")) { string title = xvideo.Element("Title").Value; string desc = xvideo.Element("Description").Value; string filePath = xvideo.Element("FilePath").Value; try { var videoId = vimeoApi.UploadVideo(filePath, title, desc, (l1, l2) => { }); InfoFormat("Video {0} uploaded to Vimeo. VideoId: {1}", filePath, videoId); if (success && !atLeastOneSuccess) { atLeastOneSuccess = true; } } catch (Exception e) { ErrorFormat("An error occured while uploading the file {0}: {1}", filePath, e.Message); success = false; } } } catch (ThreadAbortException) { throw; } catch (Exception e) { ErrorFormat("An error occured while uploading the file {0}: {1}", file.Path, e.Message); success = false; } } } catch (ThreadAbortException) { throw; } catch (Exception e) { ErrorFormat("An error occured while uploading videos: {0}", e.Message); success = false; } return(success); }
private void FolderCheckUploadComplete() { VimeoApi api = recorderObj.AddComponent <VimeoApi>(); api.token = VALID_RECORDING_TOKEN; api.OnRequestComplete += GetFoldersComplete; api.GetVideosInFolder(new VimeoFolder("Unity Tests", TEST_PROJECT_FOLDER)); }
private void SecondUploadComplete() { Debug.Log("[TEST] SecondUploadComplete"); VimeoApi api = recorderObj.AddComponent <VimeoApi>(); api.token = VALID_RECORDING_TOKEN; api.OnRequestComplete += CheckRecentVideos; api.GetRecentUserVideos("name", 2); }
private void Start() { if (!vimeoSignIn) { Debug.LogWarning("You have not signed into the Vimeo Player."); return; } if (vimeoVideoId == null || vimeoVideoId == "") { Debug.LogWarning("No Vimeo video URL was specified"); } if (GetVimeoToken() != null) { api = gameObject.AddComponent <VimeoApi>(); api.token = GetVimeoToken(); } if (videoScreen == null && videoPlayerType == VideoPlayerType.UnityPlayer) { Debug.LogWarning("No video screen was specified."); } if (videoPlayerType == VideoPlayerType.UnityPlayer) { // TODO abstract this out into a VideoPlayerManager (like EncoderManager.cs) controller = gameObject.AddComponent <VideoController>(); controller.videoScreenObject = videoScreen; controller.playerSettings = this; controller.OnVideoStart += VideoStarted; controller.OnPlay += VideoPlay; controller.OnPause += VideoPaused; controller.OnFrameReady += VideoFrameReady; } if (audioSource && audioSource is AudioSource) { if (audioSource != null) { controller.audioSource = audioSource; } else { videoScreen.gameObject.AddComponent <AudioSource>(); } } LoadVimeoVideoByUrl(vimeoVideoId); if (OnLoad != null) { OnLoad(); } }
private void Start() { if (!vimeoSignIn) { Debug.LogWarning("You have not signed into the Vimeo Player."); return; } if (GetVimeoToken() != null) { api = gameObject.AddComponent <VimeoApi>(); api.token = GetVimeoToken(); api.OnRequestComplete += OnLoadVimeoVideoComplete; } if (videoScreen == null) { Debug.LogWarning("No video screen was specified."); } if (audioSource && audioSource.GetType() == typeof(GameObject)) { if (audioSource.GetComponent <AudioSource>() != null) { controller.audioSource = audioSource.GetComponent <AudioSource>(); } else { Debug.LogWarning("No AudioSource component found on " + audioSource.name + " GameObject"); } } controller = gameObject.AddComponent <VideoController>(); controller.videoScreenObject = videoScreen; controller.playerSettings = this; controller.OnVideoStart += VideoStarted; controller.OnPlay += VideoPlay; controller.OnPause += VideoPaused; // Bootup video if (vimeoVideoId != null && vimeoVideoId != "") { vimeoVideoId = Regex.Split(vimeoVideoId, "/?([0-9]+)")[1]; LoadVimeoVideo(int.Parse(vimeoVideoId)); } else { Debug.LogWarning("No Vimeo video ID was specified"); } }
IEnumerator Post(string url, WWWForm form) { using (UnityWebRequest request = UnityWebRequest.Post(url, form)) { #if UNITY_2017_3_OR_NEWER yield return(request.SendWebRequest()); #else yield return(request.Send()); #endif if (VimeoApi.IsNetworkError(request)) { Debug.LogError(request.error); } } }
public IEnumerator Unfurl(string url) { using (UnityWebRequest www = UnityWebRequest.Get(url)) { yield return(VimeoApi.SendRequest(www)); if (!VimeoApi.IsNetworkError(www)) { m_file_url = www.url; } else { m_file_url = url; } } }
public void Init(VimeoRecorder _recorder) { recorder = _recorder; if (vimeoApi == null) { vimeoApi = gameObject.AddComponent <VimeoApi>(); vimeoApi.OnPatchComplete += VideoUpdated; vimeoApi.OnUploadComplete += UploadComplete; vimeoApi.OnUploadProgress += UploadProgress; vimeoApi.OnError += ApiError; vimeoApi.OnNetworkError += NetworkError; vimeoApi.token = recorder.GetVimeoToken(); } }
public override TaskStatus Run() { Info("Listing uploads..."); Status status = Status.Success; try { var xmlPath = Path.Combine(Workflow.WorkflowTempFolder, string.Format("{0}_{1:yyyy-MM-dd-HH-mm-ss-fff}.xml", "VimeoListUploads", DateTime.Now)); var xdoc = new XDocument(new XElement("VimeoListUploads")); var xvideos = new XElement("Videos"); VimeoApi vimeoApi = new VimeoApi(Token); var videos = vimeoApi.GetVideos(); foreach (var d in videos.data) { xvideos.Add(new XElement("Video" , new XAttribute("title", SecurityElement.Escape(d.name)) , new XAttribute("uri", SecurityElement.Escape(d.uri)) , new XAttribute("created_time", SecurityElement.Escape(d.created_time)) , new XAttribute("status", SecurityElement.Escape(d.status)) )); } xdoc.Root.Add(xvideos); xdoc.Save(xmlPath); Files.Add(new FileInf(xmlPath, Id)); InfoFormat("Results written in {0}", xmlPath); } catch (ThreadAbortException) { throw; } catch (Exception e) { ErrorFormat("An error occured while listing uploads: {0}", e.Message); status = Status.Error; } Info("Task finished."); return(new TaskStatus(status)); }
public void Start() { Application.runInBackground = true; if (api == null) { api = gameObject.AddComponent <VimeoApi>(); api.token = GetVimeoToken(); api.OnError += ApiError; } SetupVideoController(); if (autoPlay == true) { LoadAndPlayVideo(); } if (OnStart != null) { OnStart(); } }
public override TaskStatus Run() { Info("Uploading videos..."); bool succeeded = true; bool atLeastOneSucceed = false; try { var files = SelectFiles(); VimeoApi vimeoApi = new VimeoApi(Token); foreach (var file in files) { try { XDocument xdoc = XDocument.Load(file.Path); foreach (var xvideo in xdoc.XPathSelectElements("/Videos/Video")) { string title = xvideo.Element("Title").Value; string desc = xvideo.Element("Description").Value; string filePath = xvideo.Element("FilePath").Value; try { var videoId = vimeoApi.UploadVideo(filePath, title, desc, (l1, l2) => { }); InfoFormat("Video {0} uploaded to Vimeo. VideoId: {1}", filePath, videoId); if (succeeded && !atLeastOneSucceed) { atLeastOneSucceed = true; } } catch (Exception e) { ErrorFormat("An error occured while uploading the file {0}: {1}", filePath, e.Message); succeeded = false; } } } catch (ThreadAbortException) { throw; } catch (Exception e) { ErrorFormat("An error occured while uploading the file {0}: {1}", file.Path, e.Message); succeeded = false; } } } catch (ThreadAbortException) { throw; } catch (Exception e) { ErrorFormat("An error occured while uploading videos: {0}", e.Message); return(new TaskStatus(Status.Error)); } var status = Status.Success; if (!succeeded && atLeastOneSucceed) { status = Status.Warning; } else if (!succeeded) { status = Status.Error; } Info("Task finished."); return(new TaskStatus(status)); }