/// <summary> /// Sets a value read from an object's metadata XML. /// </summary> /// <param name="key"> /// The key of the property read from XML. /// </param> /// <param name="value"> /// The value of the property read from XML. /// </param> /// <returns> /// <c>true</c>, if the value was set; otherwise, <c>false</c>. /// </returns> private void SetValue(string key, string value) { if (key.Is("size")) { this.Size = ulong.Parse(value); } else if (key.Is("duration")) { this.Duration = ParsingHelper.ParseTimeSpan(value); } else if (key.Is("bitrate")) { this.Bitrate = uint.Parse(value); } else if (key.Is("sampleFrequency")) { this.SampleFrequency = uint.Parse(value); } else if (key.Is("bitsPerSample")) { this.BitsPerSample = uint.Parse(value); } else if (key.Is("nrAudioChannels")) { this.NumberOfAudioChannels = uint.Parse(value); } else if (key.Is("resolution")) { this.Resolution = ParsingHelper.ParseResolution(value); } else if (key.Is("colorDepth")) { this.ColorDepth = uint.Parse(value); } else if (key.Is("protocolInfo")) { this.ProtocolInfo = value; } else if (key.Is("protection")) { this.Protection = value; } else if (key.Is("importUri")) { this.ImportUri = value; } }
/// <summary> /// Sets a value read from an object's metadata XML. /// </summary> /// <param name="key"> /// The key of the property read from XML. /// </param> /// <param name="value"> /// The value of the property read from XML. /// </param> /// <returns> /// <c>true</c>, if the value was set; otherwise, <c>false</c>. /// </returns> protected override void SetValue(string key, string value) { if (key.Is("StorageMedium")) { this.StorageMedium = value; } else if (key.Is("longDescription")) { this.LongDescription = value; } else if (key.Is("rating")) { this.Rating = value; } else if (key.Is("description")) { this.Description = value; } else if (key.Is("publisher")) { this.Publisher = value; } else if (key.Is("date")) { this.Date = ParsingHelper.ParseDate(value); } else if (key.Is("rights")) { this.Rights = value; } else if (key.Is("albumArtURI")) { this.AlbumArtURI = value; } else { base.SetValue(key, value); } }
/// <summary> /// Returns information associated with the current position of the transport of the specified instance. /// </summary> /// <param name="instanceId"> /// Identifies the virtual instanceId of the AVTransport service to which the action applies. /// </param> /// <returns> /// An instance of <see cref="PositionInfo"/> which defines information about playback position of the specified AvTransport instance. /// </returns> /// <exception cref="WebException"> /// An error occurred when sending request to service. /// </exception> /// <exception cref="FormatException"> /// Received result is in a bad format. /// </exception> /// <exception cref="UPnPServiceException"> /// An internal service error occurred when executing request. /// </exception> public async Task <PositionInfo> GetPositionInfoAsync(uint instanceId) { var arguments = new Dictionary <string, object> { { "InstanceID", instanceId } }; var response = await this.InvokeActionAsync("GetPositionInfo", arguments); var positionInfo = new PositionInfo { Track = response.GetValueOrDefault <uint>("Track"), TrackDuration = ParsingHelper.ParseTimeSpan(response.GetValueOrDefault <string>("TrackDuration")), TrackMetaData = response.GetValueOrDefault <string>("TrackMetaData"), TrackUri = response.GetValueOrDefault <Uri>("TrackURI"), RelativeTimePosition = ParsingHelper.ParseTimeSpan(response.GetValueOrDefault <string>("RelTime")), AbsoluteTimePosition = ParsingHelper.ParseTimeSpan(response.GetValueOrDefault <string>("AbsTime")), RelativeCounterPosition = response.GetValueOrDefault <int>("RelCount"), AbsoluteCounterPosition = response.GetValueOrDefault <int>("AbsCount") }; return(positionInfo); }
/// <summary> /// Returns information associated with the current media of the specified instance. /// </summary> /// <param name="instanceId"> /// Identifies the virtual instanceId of the AVTransport service to which the action applies. /// </param> /// <returns> /// An instance of <see cref="RendererMediaInfo"/> which defines information about currently current media. /// </returns> /// <exception cref="WebException"> /// An error occurred when sending request to service. /// </exception> /// <exception cref="FormatException"> /// Received result is in a bad format. /// </exception> /// <exception cref="UPnPServiceException"> /// An internal service error occurred when executing request. /// </exception> public async Task <RendererMediaInfo> GetMediaInfoAsync(uint instanceId) { var arguments = new Dictionary <string, object> { { "InstanceID", instanceId } }; var response = await this.InvokeActionAsync("GetMediaInfo", arguments); var mediaInfo = new RendererMediaInfo { NumberOfTracks = response.GetValueOrDefault <int>("NrTracks"), MediaDuration = ParsingHelper.ParseTimeSpan(response.GetValueOrDefault <string>("MediaDuration")), CurrentUri = response.GetValueOrDefault <Uri>("CurrentURI"), CurrentUriMetadata = response.GetValueOrDefault <string>("CurrentURIMetaData"), NextUri = response.GetValueOrDefault <Uri>("NextURI"), NextUriMetadata = response.GetValueOrDefault <string>("NextURIMetaData"), PlaybackMedium = response.GetValueOrDefault <string>("PlayMedium"), RecordMedium = response.GetValueOrDefault <string>("RecordMedium"), WriteStatus = response.GetValueOrDefault <bool>("WriteStatus") }; return(mediaInfo); }