Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions PlaylistsNET/Content/HlsContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ private HlsMediaPlaylist GetMediaHls(List<string> 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;
}
Expand Down
7 changes: 4 additions & 3 deletions PlaylistsNET/Models/HlsPlaylistEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace PlaylistsNET.Models
{
using System.Globalization;

public abstract class HlsPlaylistEntry : BasePlaylistEntry
{
public Dictionary<string, string> CustomProperties { get; set; }
Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -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)
Expand Down