diff --git a/PlaylistsNET/Content/HlsContent.cs b/PlaylistsNET/Content/HlsContent.cs index 35150f4..ebe1df3 100644 --- a/PlaylistsNET/Content/HlsContent.cs +++ b/PlaylistsNET/Content/HlsContent.cs @@ -204,10 +204,10 @@ private HlsMediaPlaylist GetMediaHls(List playlistLines) continue; } - var match = Regex.Match(currentLine, @"^#EXTINF:(-?\d*),(.*)$"); + var match = Regex.Match(currentLine, @"^#EXTINF:(-?\d*\.?\d*?),(.*)$"); if (match.Success) { - currentEntry.Duration = string.IsNullOrEmpty(match.Groups[1].Value) ? 0 : int.Parse(match.Groups[1].Value); + currentEntry.Duration = string.IsNullOrEmpty(match.Groups[1].Value) ? 0 : double.Parse(match.Groups[1].Value); currentEntry.Title = match.Groups[2].Value; continue; } diff --git a/PlaylistsNET/Models/HlsPlaylistEntry.cs b/PlaylistsNET/Models/HlsPlaylistEntry.cs index 7c41dd4..2a42bea 100644 --- a/PlaylistsNET/Models/HlsPlaylistEntry.cs +++ b/PlaylistsNET/Models/HlsPlaylistEntry.cs @@ -4,6 +4,8 @@ namespace PlaylistsNET.Models { + using System.Globalization; + public abstract class HlsPlaylistEntry : BasePlaylistEntry { public Dictionary CustomProperties { get; set; } @@ -37,7 +39,7 @@ protected void CheckEmptyStringAndAppend(string tag, public class HlsMediaPlaylistEntry : HlsPlaylistEntry { - public int Duration { get; set; } + public double Duration { get; set; } public string Title { get; set; } public long MediaSequence { get; set; } public bool Discontinuity { get; set; } @@ -71,8 +73,7 @@ public override string ToString() sb.AppendLine("#EXT-X-DISCONTINUITY"); } - string durationTitle = String.Join(",", - new string[] { Duration == 0 ? "" : Duration.ToString(), Title }); + string durationTitle = String.Join(",", Duration == 0 ? "" : Duration.ToString(), Title); CheckAndAppend("#EXTINF", durationTitle, sb, dt => !dt.Equals(",")); foreach(var kv in CustomProperties)