aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-01-03 00:59:29 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-01-03 00:59:29 -0500
commit08cd8b381fd7b17afc39f2c0b2da73c5db591b7c (patch)
tree24f1ecff12550ddff20b90c44ff2cf2c05149f2d
parent60666191387b0ebdb12d2fb7b18018a2cc922087 (diff)
fix last segment length
-rw-r--r--MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs16
1 files changed, 14 insertions, 2 deletions
diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
index 3f33fd028..64be7c6c9 100644
--- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
@@ -265,9 +265,15 @@ namespace MediaBrowser.Api.Playback.Hls
double startSeconds = 0;
var lengths = GetSegmentLengths(state);
+ if (requestedIndex >= lengths.Length)
+ {
+ var msg = string.Format("Invalid segment index requested: {0} - Segment count: {1}", requestedIndex, lengths.Length);
+ throw new ArgumentException(msg);
+ }
+
for (var i = 0; i < requestedIndex; i++)
{
- startSeconds += lengths[requestedIndex];
+ startSeconds += lengths[i];
}
var position = TimeSpan.FromSeconds(startSeconds).Ticks;
@@ -279,9 +285,15 @@ namespace MediaBrowser.Api.Playback.Hls
double startSeconds = 0;
var lengths = GetSegmentLengths(state);
+ if (requestedIndex >= lengths.Length)
+ {
+ var msg = string.Format("Invalid segment index requested: {0} - Segment count: {1}", requestedIndex, lengths.Length);
+ throw new ArgumentException(msg);
+ }
+
for (var i = 0; i <= requestedIndex; i++)
{
- startSeconds += lengths[requestedIndex];
+ startSeconds += lengths[i];
}
var position = TimeSpan.FromSeconds(startSeconds).Ticks;