Skip to content

Commit

Permalink
Update LavaTrack.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
BlyZeDev authored Feb 24, 2023
1 parent 72201c8 commit 6c474ee
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/Player/LavaTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,32 @@ public LavaTrack(LavaTrack lavaTrack) {
Source = lavaTrack.Source;
}

internal static TLavaTrack Initialize<TLavaTrack>(TLavaTrack? lavaTrack,

Check warning on line 121 in src/Player/LavaTrack.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 121 in src/Player/LavaTrack.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
string hash, string id, string title, string author,
string url, TimeSpan position, long duration,
bool canSeek, bool isStream, string source) where TLavaTrack : LavaTrack
{
if (lavaTrack is null)
return (TLavaTrack)Activator.CreateInstance(
typeof(TLavaTrack),
new LavaTrack(hash, id, title, author, url, position, duration, canSeek, isStream, source));

lavaTrack.Hash = hash ?? throw new ArgumentNullException(nameof(hash));
lavaTrack.Id = id ?? throw new ArgumentNullException(nameof(id));
lavaTrack.Title = title ?? throw new ArgumentNullException(nameof(title));
lavaTrack.Author = author ?? throw new ArgumentNullException(nameof(author));
lavaTrack.Url = url ?? throw new ArgumentNullException(nameof(url));
lavaTrack.Position = position;
lavaTrack.Duration = duration < TimeSpan.MaxValue.Ticks
? TimeSpan.FromMilliseconds(duration)
: TimeSpan.MaxValue;
lavaTrack.CanSeek = canSeek;
lavaTrack.IsStream = isStream;
lavaTrack.Source = source;

return lavaTrack;
}

/// <summary>
///
/// </summary>
Expand All @@ -133,4 +159,4 @@ public override string ToString() {
return $"{Author} {Title}";
}
}
}
}

0 comments on commit 6c474ee

Please sign in to comment.