Merge branch 'MDL-83570-404' of https://github.com/meirzamoodle/moodle into MOODLE_404_STABLE

This commit is contained in:
Huong Nguyen
2024-11-20 16:11:35 +07:00
5 changed files with 96 additions and 3 deletions
@@ -0,0 +1,29 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace tiny_recordrtc;
/**
* Constants for Tiny RecordRTC plugin.
*
* @package tiny_recordrtc
* @copyright Meirza <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class constants {
/** @var array TINYRECORDRTC_AUDIO_BITRATE The audio bitrate options. */
public const TINYRECORDRTC_AUDIO_BITRATES = [24000, 32000, 48000, 64000, 96000, 128000, 160000, 192000, 256000, 320000];
}
@@ -0,0 +1,53 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Tiny text editor recordrtc plugin upgrade script.
*
* @package tiny_recordrtc
* @copyright Meirza <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Run all Tiny recordrtc upgrade steps between the current DB version and the current version on disk.
* @param int $oldversion The old version of atto equation in the DB.
* @return bool
*/
function xmldb_tiny_recordrtc_upgrade($oldversion) {
if ($oldversion < 2024042201) {
// The input bitrate to be converted.
$currentbitrate = get_config('tiny_recordrtc', 'audiobitrate');
// Supported bitrates.
$supportedbitrates = \tiny_recordrtc\constants::TINYRECORDRTC_AUDIO_BITRATES;
// Find the nearest value.
usort($supportedbitrates, fn($a, $b) => abs($currentbitrate - $a) <=> abs($currentbitrate - $b));
$nearestbitrate = $supportedbitrates[0];
// Update the bitrate setting with the nearest supported bitrate.
set_config('audiobitrate', $nearestbitrate, 'tiny_recordrtc');
// Main savepoint reached.
upgrade_main_savepoint(true, 2024042201);
}
// Automatically generated Moodle v4.4.0 release upgrade line.
// Put any upgrade step following this.
return true;
}
@@ -53,6 +53,7 @@ $string['gumtype'] = 'Tried to get stream from the webcam/microphone, but no con
$string['gumtype_title'] = 'No constraints specified';
$string['insecurealert'] = 'Your browser might not allow this plugin to work unless it is used either over HTTPS or from localhost.';
$string['insecurealert_title'] = 'Insecure connection!';
$string['kbrate'] = '{$a} kb/s';
$string['maxfilesizehit'] = 'You have reached the maximum size limit for file uploads.';
$string['maxfilesizehit_title'] = 'Recording stopped';
$string['norecordingfound'] = 'Something has gone wrong. Nothing has been recorded.';
+12 -2
View File
@@ -58,8 +58,18 @@ if ($ADMIN->fulltree) {
// Audio bitrate.
$name = get_string('audiobitrate', 'tiny_recordrtc');
$desc = get_string('audiobitrate_desc', 'tiny_recordrtc');
$default = '128000';
$setting = new admin_setting_configtext('tiny_recordrtc/audiobitrate', $name, $desc, $default, PARAM_INT, 8);
$options = [];
foreach (\tiny_recordrtc\constants::TINYRECORDRTC_AUDIO_BITRATES as $rate) {
$kbrate = $rate / 1000;
$options[$rate] = get_string('kbrate', 'tiny_recordrtc', $kbrate);
}
$setting = new admin_setting_configselect(
name: 'tiny_recordrtc/audiobitrate',
visiblename: $name,
description: $desc,
defaultsetting: \tiny_recordrtc\constants::TINYRECORDRTC_AUDIO_BITRATES[5],
choices: $options,
);
$settings->add($setting);
// Video bitrate.
@@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2024042200;
$plugin->version = 2024042201;
$plugin->requires = 2024041600;
$plugin->component = 'tiny_recordrtc';