public override async Task LoadContents() { var loader = new RemoteApiContentsLoader(TargetDevice); await TargetDevice.Observer.StartAsync(); try { OnProgressMessage("Progress_ChangingCameraState"); var StateChangeCanceller = new CancellationTokenSource(15000); try { if (!await PlaybackModeHelper.MoveToContentTransferModeAsync(TargetDevice, StateChangeCanceller)) { DebugUtil.Log(() => "ModeTransition failed"); throw new Exception(); } } finally { StateChangeCanceller = null; } DebugUtil.Log(() => "ModeTransition successfully finished"); OnProgressMessage("Progress_FetchingContents"); loader.PartLoaded += RemoteContentsLoader_PartLoaded; await loader.Load(ApplicationSettings.GetInstance().RemoteContentsSet, Canceller); DebugUtil.Log(() => "RemoteApiContentsLoader completed"); } catch (StorageNotSupportedException) { // This will never happen on camera devices. DebugUtil.Log(() => "storage scheme is not supported"); OnErrorMessage("Viewer_StorageAccessNotSupported"); } catch (NoStorageException) { DebugUtil.Log(() => "No storages"); OnErrorMessage("Viewer_NoStorage"); } catch (Exception e) { DebugUtil.Log(() => e.StackTrace); OnErrorMessage("Viewer_FailedToLoadContents"); } finally { loader.PartLoaded -= RemoteContentsLoader_PartLoaded; } }
public override async Task LoadRemainingContents(RemainingContentsHolder holder) { var loader = new RemoteApiContentsLoader(TargetDevice); loader.PartLoaded += RemoteContentsLoader_PartLoaded; try { await loader.LoadRemainingAsync(holder, ApplicationSettings.GetInstance().RemoteContentsSet, Canceller); } catch (Exception e) { DebugUtil.Log(() => e.StackTrace); OnErrorMessage("Viewer_FailedToLoadContents"); } finally { loader.PartLoaded -= RemoteContentsLoader_PartLoaded; } }