3 * Name: WebRTC Application
4 * Description: add a webrtc instance for video/audio
6 * Author: Stephen Mahood <https://friends.mayfirst.org/profile/marxistvegan>
7 * Author: Tobias Diekershoff <https://f.diekershoff.de/profile/tobias>
11 use Friendica\Core\Hook;
12 use Friendica\Core\Renderer;
15 function webrtc_install() {
16 Hook::register('app_menu', 'addon/webrtc/webrtc.php', 'webrtc_app_menu');
19 function webrtc_app_menu(App $a, array &$b)
21 $b['app_menu'][] = '<div class="app-title"><a href="webrtc">' . DI::l10n()->t('WebRTC Videochat') . '</a></div>';
24 function webrtc_addon_admin (App $a, string &$o)
26 $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/webrtc/' );
27 $o = Renderer::replaceMacros($t, [
28 '$submit' => DI::l10n()->t('Save Settings'),
31 DI::l10n()->t('WebRTC Base URL'),
32 DI::config()->get('webrtc','webrtcurl' ),
33 DI::l10n()->t('Page your users will create a WebRTC chat room on. For example you could use https://live.mayfirst.org .'),
38 function webrtc_addon_admin_post (App $a)
40 DI::config()->set('webrtc', 'webrtcurl', trim($_POST['webrtcurl'] ?? ''));
44 * This is a statement rather than an actual function definition. The simple
45 * existence of this method is checked to figure out if the addon offers a
48 function webrtc_module() {}
50 function webrtc_content(App $a): string
54 /* landingpage to create chatrooms */
55 $webrtcurl = DI::config()->get('webrtc','webrtcurl');
57 /* embedd the landing page in an iframe */
58 $o .= '<h2>'.DI::l10n()->t('Video Chat').'</h2>';
59 $o .= '<p>'.DI::l10n()->t('WebRTC is a video and audio conferencing tool that works in all modern browsers. Just create a new chat room and send the link to someone you want to chat with.').'</p>';
60 if ($webrtcurl == '') {
61 $o .= '<p>'.DI::l10n()->t('Please contact your friendica admin and send a reminder to configure the WebRTC addon.').'</p>';
63 $o .= '<iframe src="'.$webrtcurl.'" width="600px" height="600px"></iframe>';