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 |
|
|
|
|
8
|
|
|
* @copyright Copyright (c) 2019 nystudio107 |
|
|
|
|
9
|
|
|
*/ |
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace nystudio107\youtubeliveembed\variables; |
12
|
|
|
|
13
|
|
|
use nystudio107\youtubeliveembed\YoutubeLiveEmbed; |
14
|
|
|
use Twig\Markup; |
15
|
|
|
|
16
|
|
|
/** |
|
|
|
|
17
|
|
|
* @author nystudio107 |
|
|
|
|
18
|
|
|
* @package YoutubeLiveEmbed |
|
|
|
|
19
|
|
|
* @since 1.0.0 |
|
|
|
|
20
|
|
|
*/ |
|
|
|
|
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 |
|
|
|
|
30
|
|
|
* @param int $aspectRatioY |
|
|
|
|
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 |
|
|
|
|
43
|
|
|
* @param int $aspectRatioY |
|
|
|
|
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 |
|
|
|
|
56
|
|
|
* @param int $aspectRatioY |
|
|
|
|
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 |
|
|
|
|
69
|
|
|
* @param int $aspectRatioY |
|
|
|
|
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 |
|
|
|
|
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
|
|
|
|