Skip to content
/ php-m3u8 Public
forked from chrisyue/php-m3u8

An M3U8 parser / dumper in PHP.

License

Notifications You must be signed in to change notification settings

wswq0/php-m3u8

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP M3u8

M3u8 file parser / dumper

Installation

$ composer require 'chrisyue/php-m3u8:dev-master'

Usage

parser

$parser = new \Chrisyue\PhpM3u8\Parser();
$m3u8 = $parser->parse($m3u8Content);

// or with loader
class MyLoader implements LoaderInterface
{
    public function load($uri)
    {
        // return $uri content by `file_get_contents` or `guzzle`
    }
}

$parser->setLoader(new MyLoader());
$parser->parseFromUri($uri);

// fortunately you don't really need to write a `MyLoader` class because there is already a `CachableLoader` along with this library
// supposing you are using psr6 compatible cache utils like Symfony cache component
$cachePool = new \Symfony\Component\Cache\Adapter\ApcuAdapter();
$loader = new \Chrisyue\PhpM3u8\CachableLoader($cachePool);
$parser->setLoader($loader);
$m3u8 = $parser->parseFromUri($uri);

dumper

class MyMediaSegmentUriProcessor implements MediaSegmentUriProcessorInterface
{
    public function process(\Chrisyue\PhpM3u8\MediaSegment $mediaSegment)
    {
        return $mediaSegment->getUri();
        // or you'd like to make the uri absolute path
        // return sprintf('http://example.com/%s', $mediaSegment->getUri());
    }
}

$dumper = new \Chrisyue\PhpM3u8\Dumper(new MyMediaSegmentUriProcessor());
echo $dumper->dump($m3u8);

About

An M3U8 parser / dumper in PHP.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%