fix: KeyNotFoundException

KeyNotFoundException: The given key 'time' was not present in the dictionary.
This commit is contained in:
Robin C. Ladiges 2024-04-27 23:07:40 +02:00 committed by Sanae
parent 4de654b6e4
commit 497b5b44d6
1 changed files with 2 additions and 2 deletions

View File

@ -101,8 +101,8 @@ public class Client : IDisposable {
}
public TagPacket? GetTagPacket() {
var time = (Time?) this.Metadata?["time"];
var seek = (bool?) this.Metadata?["seeking"];
var time = (Time?) (this.Metadata.ContainsKey("time") ? this.Metadata["time"] : null);
var seek = (bool?) (this.Metadata.ContainsKey("seeking") ? this.Metadata["seeking"] : null);
if (time == null && seek == null) { return null; }
return new TagPacket {
UpdateType = (seek != null ? TagPacket.TagUpdate.State : 0) | (time != null ? TagPacket.TagUpdate.Time: 0),