1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* YouTube Live Embed plugin for Craft CMS 3.x |
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 |
|
|
|
|
8
|
|
|
* @copyright Copyright (c) 2019 nystudio107 |
|
|
|
|
9
|
|
|
*/ |
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace nystudio107\youtubeliveembed\variables; |
12
|
|
|
|
13
|
|
|
use nystudio107\youtubeliveembed\YoutubeLiveEmbed; |
14
|
|
|
|
15
|
|
|
/** |
|
|
|
|
16
|
|
|
* @author nystudio107 |
|
|
|
|
17
|
|
|
* @package YoutubeLiveEmbed |
|
|
|
|
18
|
|
|
* @since 1.0.0 |
|
|
|
|
19
|
|
|
*/ |
|
|
|
|
20
|
|
|
class YoutubeLiveEmbedVariable |
21
|
|
|
{ |
22
|
|
|
// Public Methods |
23
|
|
|
// ========================================================================= |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Renders the responsive iframe for the live stream video |
27
|
|
|
* |
28
|
|
|
* @param int $aspectRatioX |
|
|
|
|
29
|
|
|
* @param int $aspectRatioY |
|
|
|
|
30
|
|
|
* |
31
|
|
|
* @return \Twig_Markup |
32
|
|
|
*/ |
33
|
|
|
public function embedStream(int $aspectRatioX = 16, int $aspectRatioY = 9): \Twig_Markup |
34
|
|
|
{ |
35
|
|
|
return YoutubeLiveEmbed::$plugin->embed->embedStream($aspectRatioX, $aspectRatioY); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Renders the responsive Google AMP iframe for the live stream video |
40
|
|
|
* |
41
|
|
|
* @param int $aspectRatioX |
|
|
|
|
42
|
|
|
* @param int $aspectRatioY |
|
|
|
|
43
|
|
|
* |
44
|
|
|
* @return \Twig_Markup |
45
|
|
|
*/ |
46
|
|
|
public function embedStreamAmp(int $aspectRatioX = 16, int $aspectRatioY = 9): \Twig_Markup |
47
|
|
|
{ |
48
|
|
|
return YoutubeLiveEmbed::$plugin->embed->embedStreamAmp($aspectRatioX, $aspectRatioY); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Renders the responsive iframe HTML for the live stream chat |
53
|
|
|
* |
54
|
|
|
* @param int $aspectRatioX |
|
|
|
|
55
|
|
|
* @param int $aspectRatioY |
|
|
|
|
56
|
|
|
* |
57
|
|
|
* @return \Twig_Markup |
58
|
|
|
*/ |
59
|
|
|
public function embedChat(int $aspectRatioX = 16, int $aspectRatioY = 9): \Twig_Markup |
60
|
|
|
{ |
61
|
|
|
return YoutubeLiveEmbed::$plugin->embed->embedChat($aspectRatioX, $aspectRatioY); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Renders the responsive Google AMP iframe HTML for the live stream chat |
66
|
|
|
* |
67
|
|
|
* @param int $aspectRatioX |
|
|
|
|
68
|
|
|
* @param int $aspectRatioY |
|
|
|
|
69
|
|
|
* |
70
|
|
|
* @return \Twig_Markup |
71
|
|
|
*/ |
72
|
|
|
public function embedChatAmp(int $aspectRatioX = 16, int $aspectRatioY = 9): \Twig_Markup |
73
|
|
|
{ |
74
|
|
|
return YoutubeLiveEmbed::$plugin->embed->embedChatAmp($aspectRatioX, $aspectRatioY); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Sets the YouTube Channel ID to $channelId |
79
|
|
|
* |
80
|
|
|
* @param string $channelId |
|
|
|
|
81
|
|
|
* |
82
|
|
|
* @return string |
83
|
|
|
*/ |
84
|
|
|
public function setChannelId(string $channelId): string |
85
|
|
|
{ |
86
|
|
|
YoutubeLiveEmbed::$plugin->embed->setChannelId($channelId); |
87
|
|
|
|
88
|
|
|
return ''; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Returns whether the stream is currently live |
93
|
|
|
* |
94
|
|
|
* @return bool |
95
|
|
|
*/ |
96
|
|
|
public function isLive(): bool |
97
|
|
|
{ |
98
|
|
|
return YoutubeLiveEmbed::$plugin->embed->isLive(); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|