1 | <?php |
||
2 | /** |
||
3 | * YouTube Live Embed plugin for Craft CMS |
||
4 | * |
||
5 | * This plugin allows you to embed a YouTube live stream and/or live chat on your webpage |
||
6 | * |
||
7 | * @link https://nystudio107.com |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
8 | * @copyright Copyright (c) 2019 nystudio107 |
||
0 ignored issues
–
show
|
|||
9 | */ |
||
0 ignored issues
–
show
|
|||
10 | |||
11 | namespace nystudio107\youtubeliveembed\variables; |
||
12 | |||
13 | use nystudio107\youtubeliveembed\YoutubeLiveEmbed; |
||
14 | use Twig\Markup; |
||
15 | |||
16 | /** |
||
0 ignored issues
–
show
|
|||
17 | * @author nystudio107 |
||
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
![]() |
|||
18 | * @package YoutubeLiveEmbed |
||
0 ignored issues
–
show
|
|||
19 | * @since 1.0.0 |
||
0 ignored issues
–
show
|
|||
20 | */ |
||
0 ignored issues
–
show
|
|||
21 | class YoutubeLiveEmbedVariable |
||
22 | { |
||
23 | // Public Methods |
||
24 | // ========================================================================= |
||
25 | |||
26 | /** |
||
27 | * Renders the responsive iframe for the live stream video |
||
28 | * |
||
29 | * @param int $aspectRatioX |
||
0 ignored issues
–
show
|
|||
30 | * @param int $aspectRatioY |
||
0 ignored issues
–
show
|
|||
31 | * |
||
32 | * @return Markup |
||
33 | */ |
||
34 | public function embedStream(int $aspectRatioX = 16, int $aspectRatioY = 9): Markup |
||
35 | { |
||
36 | return YoutubeLiveEmbed::$plugin->embed->embedStream($aspectRatioX, $aspectRatioY); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Renders the responsive Google AMP iframe for the live stream video |
||
41 | * |
||
42 | * @param int $aspectRatioX |
||
0 ignored issues
–
show
|
|||
43 | * @param int $aspectRatioY |
||
0 ignored issues
–
show
|
|||
44 | * |
||
45 | * @return Markup |
||
46 | */ |
||
47 | public function embedStreamAmp(int $aspectRatioX = 16, int $aspectRatioY = 9): Markup |
||
48 | { |
||
49 | return YoutubeLiveEmbed::$plugin->embed->embedStreamAmp($aspectRatioX, $aspectRatioY); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Renders the responsive iframe HTML for the live stream chat |
||
54 | * |
||
55 | * @param int $aspectRatioX |
||
0 ignored issues
–
show
|
|||
56 | * @param int $aspectRatioY |
||
0 ignored issues
–
show
|
|||
57 | * |
||
58 | * @return Markup |
||
59 | */ |
||
60 | public function embedChat(int $aspectRatioX = 16, int $aspectRatioY = 9): Markup |
||
61 | { |
||
62 | return YoutubeLiveEmbed::$plugin->embed->embedChat($aspectRatioX, $aspectRatioY); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Renders the responsive Google AMP iframe HTML for the live stream chat |
||
67 | * |
||
68 | * @param int $aspectRatioX |
||
0 ignored issues
–
show
|
|||
69 | * @param int $aspectRatioY |
||
0 ignored issues
–
show
|
|||
70 | * |
||
71 | * @return Markup |
||
72 | */ |
||
73 | public function embedChatAmp(int $aspectRatioX = 16, int $aspectRatioY = 9): Markup |
||
74 | { |
||
75 | return YoutubeLiveEmbed::$plugin->embed->embedChatAmp($aspectRatioX, $aspectRatioY); |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * Sets the YouTube Channel ID to $channelId |
||
80 | * |
||
81 | * @param string $channelId |
||
0 ignored issues
–
show
|
|||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | public function setChannelId(string $channelId): string |
||
86 | { |
||
87 | YoutubeLiveEmbed::$plugin->embed->setChannelId($channelId); |
||
88 | |||
89 | return ''; |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * Returns whether the stream is currently live |
||
94 | * |
||
95 | * @return bool |
||
96 | */ |
||
97 | public function isLive(): bool |
||
98 | { |
||
99 | return YoutubeLiveEmbed::$plugin->embed->isLive(); |
||
100 | } |
||
101 | } |
||
102 |