Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Atto recordrtc library functions 19 * 20 * @package atto_recordrtc 21 * @author Jesus Federico (jesus [at] blindsidenetworks [dt] com) 22 * @author Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com) 23 * @copyright 2017 Blindside Networks Inc. 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 /** 30 * Default maximum recording length allowed for the audio/video clips. 31 */ 32 define('DEFAULT_TIME_LIMIT', 120); 33 34 /** 35 * Set params for this plugin. 36 * 37 * @param string $elementid 38 * @param stdClass $options - the options for the editor, including the context. 39 * @param stdClass $fpoptions - unused. 40 */ 41 function atto_recordrtc_params_for_js($elementid, $options, $fpoptions) { 42 $context = $options['context']; 43 if (!$context) { 44 $context = context_system::instance(); 45 } 46 47 $sesskey = sesskey(); 48 $allowedtypes = get_config('atto_recordrtc', 'allowedtypes'); 49 $audiobitrate = get_config('atto_recordrtc', 'audiobitrate'); 50 $videobitrate = get_config('atto_recordrtc', 'videobitrate'); 51 $audiotimelimit = get_config('atto_recordrtc', 'audiotimelimit'); 52 $videotimelimit = get_config('atto_recordrtc', 'videotimelimit'); 53 54 // Update $allowedtypes to account for capabilities. 55 $audioallowed = $allowedtypes === 'audio' || $allowedtypes === 'both'; 56 $videoallowed = $allowedtypes === 'video' || $allowedtypes === 'both'; 57 $audioallowed = $audioallowed && has_capability('atto/recordrtc:recordaudio', $context); 58 $videoallowed = $videoallowed && has_capability('atto/recordrtc:recordvideo', $context); 59 if ($audioallowed && $videoallowed) { 60 $allowedtypes = 'both'; 61 } else if ($audioallowed) { 62 $allowedtypes = 'audio'; 63 } else if ($videoallowed) { 64 $allowedtypes = 'video'; 65 } else { 66 $allowedtypes = ''; 67 } 68 69 $maxrecsize = get_max_upload_file_size(); 70 if (!empty($options['maxbytes'])) { 71 $maxrecsize = min($maxrecsize, $options['maxbytes']); 72 } 73 $audiortcicon = 'i/audiortc'; 74 $videortcicon = 'i/videortc'; 75 $params = array('contextid' => $context->id, 76 'sesskey' => $sesskey, 77 'allowedtypes' => $allowedtypes, 78 'audiobitrate' => $audiobitrate, 79 'videobitrate' => $videobitrate, 80 'audiotimelimit' => $audiotimelimit, 81 'videotimelimit' => $videotimelimit, 82 'defaulttimelimit' => DEFAULT_TIME_LIMIT, 83 'audiortcicon' => $audiortcicon, 84 'videortcicon' => $videortcicon, 85 'maxrecsize' => $maxrecsize 86 ); 87 88 return $params; 89 } 90 91 /** 92 * Initialise the js strings required for this module. 93 */ 94 function atto_recordrtc_strings_for_js() { 95 global $PAGE; 96 97 $strings = array('audiortc', 98 'videortc', 99 'nowebrtc_title', 100 'nowebrtc', 101 'gumabort_title', 102 'gumabort', 103 'gumnotallowed_title', 104 'gumnotallowed', 105 'gumnotfound_title', 106 'gumnotfound', 107 'gumnotreadable_title', 108 'gumnotreadable', 109 'gumnotsupported', 110 'gumnotsupported_title', 111 'gumoverconstrained_title', 112 'gumoverconstrained', 113 'gumsecurity_title', 114 'gumsecurity', 115 'gumtype_title', 116 'gumtype', 117 'insecurealert_title', 118 'insecurealert', 119 'startrecording', 120 'recordagain', 121 'stoprecording', 122 'recordingfailed', 123 'attachrecording', 124 'norecordingfound_title', 125 'norecordingfound', 126 'nearingmaxsize_title', 127 'nearingmaxsize', 128 'uploadprogress', 129 'uploadfailed', 130 'uploadfailed404', 131 'uploadaborted' 132 ); 133 134 $PAGE->requires->strings_for_js($strings, 'atto_recordrtc'); 135 } 136 137 /** 138 * Map icons for font-awesome themes. 139 */ 140 function atto_recordrtc_get_fontawesome_icon_map() { 141 return [ 142 'atto_recordrtc:i/audiortc' => 'fa-microphone', 143 'atto_recordrtc:i/videortc' => 'fa-video-camera' 144 ]; 145 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body