private void Initialize() { this.positionChangesObservableSequence = new OnDemandObservable <TimeSpan>(o => { var subscription = Observable.Timer(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1)).Subscribe( async _ => { try { var positionInfo = await this.avTransportService.GetPositionInfoAsync(0); if (this.currentPosition != positionInfo.RelativeTimePosition) { this.currentPosition = positionInfo.RelativeTimePosition; o.OnNext(positionInfo.RelativeTimePosition); } } catch (WebException ex) { this.logger.LogWarning(ex, "An error occurred when requesting position info", "Renderer".As(this.FriendlyName)); } catch (FormatException ex) { this.logger.LogWarning(ex, "An error occurred when requesting position info", "Renderer".As(this.FriendlyName)); } catch (UPnPServiceException ex) { this.logger.LogWarning(ex, "An error occurred when requesting position info", "Renderer".As(this.FriendlyName)); } }); return(subscription.Dispose); }); this.stateChangesObservableSequence = new OnDemandObservable <MediaRendererState>(o => { var subscription = Observable.Timer(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1)).Subscribe( async _ => { try { var info = await this.avTransportService.GetTransportInfoAsync(0); var state = ParseTransportState(info.State); if (this.currentState != state) { this.currentState = state; o.OnNext(ParseTransportState(info.State)); } } catch (WebException ex) { this.logger.LogWarning(ex, "An error occurred when requesting state info", "Renderer".As(this.FriendlyName)); } catch (FormatException ex) { this.logger.LogWarning(ex, "An error occurred when requesting state info", "Renderer".As(this.FriendlyName)); } catch (UPnPServiceException ex) { this.logger.LogWarning(ex, "An error occurred when requesting state info", "Renderer".As(this.FriendlyName)); } }); return(subscription.Dispose); }); //*/ }
private void Initialize() { this.positionChangesObservableSequence = new OnDemandObservable<TimeSpan>(o => { var subscription = Observable.Timer(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1)).Subscribe( async _ => { try { var positionInfo = await this.avTransportService.GetPositionInfoAsync(0); if (this.currentPosition != positionInfo.RelativeTimePosition) { this.currentPosition = positionInfo.RelativeTimePosition; o.OnNext(positionInfo.RelativeTimePosition); } } catch (WebException ex) { this.logger.Instance().Warning(ex, "An error occurred when requesting position info", "Renderer".As(this.FriendlyName)); } catch (FormatException ex) { this.logger.Instance().Warning(ex, "An error occurred when requesting position info", "Renderer".As(this.FriendlyName)); } catch (UPnPServiceException ex) { this.logger.Instance().Warning(ex, "An error occurred when requesting position info", "Renderer".As(this.FriendlyName)); } }); return subscription.Dispose; }); this.stateChangesObservableSequence = new OnDemandObservable<MediaRendererState>(o => { var subscription = Observable.Timer(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1)).Subscribe( async _ => { try { var info = await this.avTransportService.GetTransportInfoAsync(0); var state = ParseTransportState(info.State); if (this.currentState != state) { this.currentState = state; o.OnNext(ParseTransportState(info.State)); } } catch (WebException ex) { this.logger.Instance().Warning(ex, "An error occurred when requesting state info", "Renderer".As(this.FriendlyName)); } catch (FormatException ex) { this.logger.Instance().Warning(ex, "An error occurred when requesting state info", "Renderer".As(this.FriendlyName)); } catch (UPnPServiceException ex) { this.logger.Instance().Warning(ex, "An error occurred when requesting state info", "Renderer".As(this.FriendlyName)); } }); return subscription.Dispose; }); }