Skip to content
Merged
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 .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -58,7 +58,7 @@ jobs:
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest

- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.composer/cache/files
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}-dep-${{ matrix.dependency-version }}
Expand Down
18 changes: 17 additions & 1 deletion src/Exporters/HLSExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,23 @@ public function withPlaylistGenerator(PlaylistGenerator $playlistGenerator): sel

private function getPlaylistGenerator(): PlaylistGenerator
{
return $this->playlistGenerator ?: new HLSPlaylistGenerator();
return $this->playlistGenerator ??= new HLSPlaylistGenerator();
}

/**
* Method to not add the #EXT-X-ENDLIST line to the playlist.
*
* @return self
*/
public function withoutPlaylistEndLine(): self
{
$playlistGenerator = $this->getPlaylistGenerator();

if ($playlistGenerator instanceof HLSPlaylistGenerator) {
$playlistGenerator->withoutEndLine();
}

return $this;
}

/**
Expand Down
16 changes: 15 additions & 1 deletion src/Exporters/HLSPlaylistGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ class HLSPlaylistGenerator implements PlaylistGenerator
public const PLAYLIST_START = '#EXTM3U';
public const PLAYLIST_END = '#EXT-X-ENDLIST';

protected bool $withEndLine = true;

/**
* Adds the #EXT-X-ENDLIST tag to the end of the playlist.
*
* @return $this
*/
public function withoutEndLine(): self
{
$this->withEndLine = false;

return $this;
}

/**
* Return the line from the master playlist that references the given segment playlist.
*
Expand Down Expand Up @@ -58,7 +72,7 @@ public function get(array $segmentPlaylists, PHPFFMpeg $driver): string
return [$streamInfoLine, $segmentPlaylist->getFilename()];
})->collapse()
->prepend(static::PLAYLIST_START)
->push(static::PLAYLIST_END)
->when($this->withEndLine, fn (Collection $lines) => $lines->push(static::PLAYLIST_END))
->implode(PHP_EOL);
}
}
Loading