podlove / webvtt-parser
用于解析WebVTT的PHP库
v1.1.6
2022-07-25 17:45 UTC
Requires
- php: >=5.3.0
Requires (Dev)
- phpunit/phpunit: 7.*.*
README
PHP库,用于解析WebVTT文件。
它遵循W3C规范,但并不完整。例如,它没有对CSS样式进行特殊处理。
使用方法
use Podlove\Webvtt\Parser; use Podlove\Webvtt\ParserException; $parser = new Podlove\Webvtt\Parser(); $content = "WEBVTT\n\n00:00:00.000 --> 01:22:33.440\nHello world\n\n01:22:33.440 --> 01:22:34.440\n<v Eric>Hi again\n"; $result = $parser->parse($content); // [ // "cues" => [ // [ // "voice" => "", // "start" => 0, // "end" => 4953.44, // "text" => "Hello world", // "identifier" => "", // ], // [ // "voice" => "Eric", // "start" => 4953.44, // "end" => 4954.44, // "text" => "Hi again", // "identifier" => "", // ], // ], // ]