leequix / icecast-streamer
用于将流媒体发送到 icecast 的 Composer 包
1.0.0
2018-01-25 14:18 UTC
Requires (Dev)
This package is not auto-updated.
Last update: 2024-09-29 06:46:12 UTC
README
Icecast-streamer 是将 mp3 流媒体发送到 icecast 的库。
流示例
require_once __DIR__ . '/vendor/autoload.php'; use IcecastStreamer\Stream; use IcecastStreamer\Stream\MountPoint; use IcecastStreamer\Stream\Connection; use IcecastStreamer\Stream\AuthCredentials; use IcecastStreamer\Stream\Info; $mountPoint = new MountPoint('/live', new AuthCredentials('source', 'hackme')); $connection = new Connection('localhost', 8000, $mountPoint); $info = new Info(); $info->setContentType('audio/mpeg'); $info->setName('Super cool stream'); $info->setDescription('My first stream'); $info->setGenre('drum and base'); $info->setUrl('http://leequix.xyz'); $stream = new Stream($connection, $info); try { $stream->start(); } catch (Exception $exception) { echo $exception->getMessage(); } $file = fopen('./imperial_march.mp3', 'r'); while ($data = fread($file, 24567)) { $stream->write($data); echo ('[' . date('H:i:s') . '] I am send ' . strlen($data) . ' bytes of data!' . PHP_EOL); sleep(1); } fclose($file); $stream->stop();
文档位于 /docs
目录中。