Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
MediaPlayParams
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
1 / 1
 toPdf
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
4
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Core\Multimedia;
6
7use Phpdftk\Pdf\Core\PdfDictionary;
8use Phpdftk\Pdf\Core\PdfName;
9use Phpdftk\Pdf\Core\PdfObject;
10use Phpdftk\Pdf\Core\PdfVersion;
11use 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)]
22class 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}