private void OnLoad(string errorMessage) { if (string.IsNullOrEmpty(errorMessage)) { LoadSuccessful?.Invoke(); } else { LoadFailed?.Invoke(errorMessage); } }
private void OnWebViewLoadError(object sender, LoadErrorEventArgs e) { var url = e.FailedUrl; if (UrlHelper.IsChromeInternalUrl(url)) { return; } if (e.Frame.IsMain && url == DefaultLocalUrl) { // failed loading default local url, discard html htmlToLoad = null; } if (e.ErrorCode != CefErrorCode.Aborted && LoadFailed != null) { var frameName = e.Frame.Name; // store frame name beforehand (cannot do it later, since frame might be disposed) // ignore aborts, to prevent situations where we try to load an address inside Load failed handler (and its aborted) AsyncExecuteInUI(() => LoadFailed?.Invoke(url, (int)e.ErrorCode, frameName)); } }
public async Task <MediaStatus> LoadAsync( MediaInformation media, bool autoPlay = true, double seekedSeconds = 0, params int[] activeTrackIds) { _logger.LogInfo($"{nameof(LoadAsync)}: Trying to load media = {media.ContentId}"); CurrentContentId = null; CancelAndSetListenerToken(); FileLoading?.Invoke(this, EventArgs.Empty); var app = await _receiverChannel.GetApplication(_sender, _connectionChannel, _mediaChannel.Namespace); var status = await _mediaChannel.LoadAsync(_sender, app.SessionId, media, autoPlay, activeTrackIds); if (status is null) { LoadFailed?.Invoke(this, EventArgs.Empty); _logger.LogWarn($"{nameof(LoadAsync)}: Couldn't load media {media.ContentId}"); return(null); } CurrentContentId = media.ContentId; CurrentMediaDuration = media.Duration ?? status?.Media?.Duration ?? 0; CurrentVolumeLevel = status?.Volume?.Level ?? 0; IsMuted = status?.Volume?.IsMuted ?? false; ElapsedSeconds = 0; _seekedSeconds = seekedSeconds; TriggerTimeEvents(); IsPlaying = true; IsPaused = false; ListenForMediaChanges(_listenerToken.Token); ListenForReceiverChanges(_listenerToken.Token); FileLoaded?.Invoke(this, EventArgs.Empty); _logger.LogInfo($"{nameof(LoadAsync)}: Media = {media.ContentId} was loaded. Duration = {CurrentMediaDuration} - SeekSeconds = {_seekedSeconds}"); return(status); }
public void OnLoadFailure(EventArgs e) { LoadFailed?.Invoke(this, e); }
public void OnRendererLoadFailed(string messageId, bool retriable, MessageFailureStatus status) { LoadFailed?.Invoke(this, new MessageLoadFailedEventArgs(messageId, retriable, status)); }
/// <summary> /// This method will load a song and its settings from a file at the "path" variable's destination /// This loading method handles all previous save formats for backwards compatibility /// </summary> public static void LoadSong(string path) { Song.Clear(); bool errorWhileLoading = true; StreamReader sr = new StreamReader(path); string firstLine = sr.ReadLine(); #region 2.1+ save format if (SupportedVersionsSave.Contains(firstLine)) { if (sr.ReadLine() == "DELAYS") { int delayCount = 0; if (int.TryParse(sr.ReadLine(), out delayCount) && delayCount > 0) { for (int i = 0; i < delayCount; i++) { char delayChar; int delayTime = 0; if (char.TryParse(sr.ReadLine(), out delayChar)) { if (int.TryParse(sr.ReadLine(), out delayTime)) { Delays.Add(new Delay(delayChar, delayTime)); } } } } } if (sr.ReadLine() == "CUSTOM NOTES") { int noteCount = 0; if (int.TryParse(sr.ReadLine(), out noteCount) && noteCount > 0) { for (int i = 0; i < noteCount; i++) { char origNoteChar; char replaceNoteChar; if (char.TryParse(sr.ReadLine(), out origNoteChar)) { if (char.TryParse(sr.ReadLine(), out replaceNoteChar)) { WindowsInput.Native.VirtualKeyCode vkOld; WindowsInput.Native.VirtualKeyCode vkNew; try { VirtualDictionary.TryGetValue(origNoteChar, out vkOld); VirtualDictionary.TryGetValue(replaceNoteChar, out vkNew); if (vkOld == 0 || vkNew == 0) { return; } } catch (ArgumentNullException) { return; } CustomNotes.Add(new Note(origNoteChar, vkOld, char.IsUpper(origNoteChar)), new Note(replaceNoteChar, vkNew, char.IsUpper(replaceNoteChar))); } } } } } if (sr.ReadLine() == "SPEEDS") { int normalSpeed, fastSpeed; int.TryParse(sr.ReadLine(), out normalSpeed); int.TryParse(sr.ReadLine(), out fastSpeed); DelayAtNormalSpeed = normalSpeed; DelayAtFastSpeed = fastSpeed; } if (sr.ReadLine() == "NOTES") { int noteCount = 0; if (int.TryParse(sr.ReadLine(), out noteCount) && noteCount > 0) { AddNotesFromString(sr.ReadToEnd()); } errorWhileLoading = false; } } #endregion #region 2.0 save format (for backwards compatibility) if (firstLine == "DELAYS") { int delayCount = 0; if (int.TryParse(sr.ReadLine(), out delayCount) && delayCount > 0) { for (int i = 0; i < delayCount; i++) { char delayChar; int delayTime = 0; if (char.TryParse(sr.ReadLine(), out delayChar)) { if (int.TryParse(sr.ReadLine(), out delayTime)) { Delays.Add(new Delay(delayChar, delayTime)); } } } } if (sr.ReadLine() == "NOTES") { int noteCount = 0; if (int.TryParse(sr.ReadLine(), out noteCount) && noteCount > 0) { AddNotesFromString(sr.ReadToEnd()); } errorWhileLoading = false; } } #endregion #region 1.2.2 save format (For backwards compatibility) else if (firstLine == "CUSTOM DELAYS") { int delayCount = 0; if (int.TryParse(sr.ReadLine(), out delayCount)) { if (sr.ReadLine() == "NORMAL DELAY") { if (int.TryParse(sr.ReadLine(), out delayAtNormalSpeed)) { Delays.Add(new Delay(' ', DelayAtNormalSpeed)); if (sr.ReadLine() == "FAST DELAY") { if (int.TryParse(sr.ReadLine(), out delayAtFastSpeed)) { if (delayCount != 0) { for (int i = 0; i < delayCount; i++) { int customDelayIndex = 0; int customDelayTime = 0; char customDelayChar; if (sr.ReadLine() == "CUSTOM DELAY INDEX") { if (int.TryParse(sr.ReadLine(), out customDelayIndex)) { if (sr.ReadLine() == "CUSTOM DELAY CHARACTER") { if (char.TryParse(sr.ReadLine(), out customDelayChar)) { if (sr.ReadLine() == "CUSTOM DELAY TIME") { if (int.TryParse(sr.ReadLine(), out customDelayTime)) { Delays.Add(new Delay(customDelayChar, customDelayTime)); } } } } } } } } if (sr.ReadLine() == "NOTES") { AddNotesFromString(sr.ReadToEnd()); errorWhileLoading = false; } } } } } } } #endregion #region 1.0 save format (For backwards compatibility) else if (firstLine == "NORMAL DELAY") { if (int.TryParse(sr.ReadLine(), out delayAtNormalSpeed)) { if (sr.ReadLine() == "FAST DELAY") { if (int.TryParse(sr.ReadLine(), out delayAtFastSpeed)) { if (sr.ReadLine() == "NOTES") { AddNotesFromString(sr.ReadToEnd()); errorWhileLoading = false; } } } } } #endregion sr.Close(); if (errorWhileLoading) { LoadFailed?.Invoke(); throw new AutoplayerLoadFailedException("No compatible save format was found!"); } LoadCompleted?.Invoke(); }