Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| MediaPlayParams | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
4 | |
100.00% |
1 / 1 |
| toPdf | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
4 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\Multimedia; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\PdfDictionary; |
| 8 | use Phpdftk\Pdf\Core\PdfName; |
| 9 | use Phpdftk\Pdf\Core\PdfObject; |
| 10 | use Phpdftk\Pdf\Core\PdfVersion; |
| 11 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 12 | |
| 13 | /** |
| 14 | * Media play parameters (/Type /MediaPlayParams) — ISO 32000-2 §13.2.5. |
| 15 | * |
| 16 | * Describes how a media clip should play (volume, rate, duration, etc.). |
| 17 | * The spec splits "must-honor" and "best-effort" parameters into two sub |
| 18 | * dicts (MH and BE) that may carry entries like V (volume), F (fit), |
| 19 | * PL (playback list), D (duration), A (auto-play), C (controller). |
| 20 | */ |
| 21 | #[RequiresPdfVersion(PdfVersion::V1_5)] |
| 22 | class MediaPlayParams extends PdfObject |
| 23 | { |
| 24 | public const PDF_TYPE = 'MediaPlayParams'; |
| 25 | |
| 26 | public ?PdfDictionary $mh = null; // /MH must-honor |
| 27 | public ?PdfDictionary $be = null; // /BE best-effort |
| 28 | public ?PdfDictionary $pl = null; // /PL player-list |
| 29 | |
| 30 | public function toPdf(): string |
| 31 | { |
| 32 | $dict = new PdfDictionary(); |
| 33 | $dict->set('Type', new PdfName(self::PDF_TYPE)); |
| 34 | if ($this->mh !== null) { |
| 35 | $dict->set('MH', $this->mh); |
| 36 | } |
| 37 | if ($this->be !== null) { |
| 38 | $dict->set('BE', $this->be); |
| 39 | } |
| 40 | if ($this->pl !== null) { |
| 41 | $dict->set('PL', $this->pl); |
| 42 | } |
| 43 | return $dict->toPdf(); |
| 44 | } |
| 45 | } |