diff --git a/lib/exstream_web/controllers/playlist_controller.ex b/lib/exstream_web/controllers/playlist_controller.ex index e9bee78..64ef555 100644 --- a/lib/exstream_web/controllers/playlist_controller.ex +++ b/lib/exstream_web/controllers/playlist_controller.ex @@ -2,17 +2,17 @@ defmodule ExstreamWeb.PlaylistController do use ExstreamWeb, :controller defp get_extinf(url, path, duration) do - steps = floor((Extaima.parse(duration) |> Extaima.seconds()) / 10) + steps = floor((Extaima.parse(duration) |> Extaima.seconds()) / 5) Enum.map_join(1..steps, fn step -> - "#EXTINF:10,\n#{url}?path=#{path}&start=#{step * 10 - 10}&end=#{step * 10}\n" + "#EXTINF:5,\n#{url}?path=#{path}&start=#{step * 5 - 5}&end=#{step * 5}\n" end) end def build(url, path, duration) do "#EXTM3U\n" <> "#EXT-X-PLAYLIST-TYPE:VOD\n" <> - "#EXT-X-TARGETDURATION:10\n" <> + "#EXT-X-TARGETDURATION:5\n" <> "#EXT-X-VERSION:4\n" <> "#EXT-X-MEDIA-SEQUENCE:0\n" <> get_extinf(url, path, duration) <> diff --git a/test/fixtures/playlist.m3u8 b/test/fixtures/playlist.m3u8 index a400ef6..d21f4a9 100644 --- a/test/fixtures/playlist.m3u8 +++ b/test/fixtures/playlist.m3u8 @@ -1,12 +1,18 @@ #EXTM3U #EXT-X-PLAYLIST-TYPE:VOD -#EXT-X-TARGETDURATION:10 +#EXT-X-TARGETDURATION:5 #EXT-X-VERSION:4 #EXT-X-MEDIA-SEQUENCE:0 -#EXTINF:10, -/some/url?path=dev/sample__1080__libx265__ac3__30s__video.mkv&start=0&end=10 -#EXTINF:10, -/some/url?path=dev/sample__1080__libx265__ac3__30s__video.mkv&start=10&end=20 -#EXTINF:10, -/some/url?path=dev/sample__1080__libx265__ac3__30s__video.mkv&start=20&end=30 +#EXTINF:5, +/some/url?path=dev/sample__1080__libx265__ac3__30s__video.mkv&start=0&end=5 +#EXTINF:5, +/some/url?path=dev/sample__1080__libx265__ac3__30s__video.mkv&start=5&end=10 +#EXTINF:5, +/some/url?path=dev/sample__1080__libx265__ac3__30s__video.mkv&start=10&end=15 +#EXTINF:5, +/some/url?path=dev/sample__1080__libx265__ac3__30s__video.mkv&start=15&end=20 +#EXTINF:5, +/some/url?path=dev/sample__1080__libx265__ac3__30s__video.mkv&start=20&end=25 +#EXTINF:5, +/some/url?path=dev/sample__1080__libx265__ac3__30s__video.mkv&start=25&end=30 #EXT-X-ENDLIST \ No newline at end of file