Call Flow - Edit: Make audio playback code consistent with other apps.

This commit is contained in:
fusionate 2023-11-07 02:21:54 +00:00
parent 62d67f3557
commit 09f92fef5f
No known key found for this signature in database
1 changed files with 41 additions and 13 deletions

View File

@ -579,15 +579,29 @@
foreach ($audio_files as $key => $value) {
echo "<optgroup label=".$text['label-'.$key]." data-type='".$key."'>\n";
foreach ($value as $row) {
if (!empty($instance_value) && $instance_value == $row["value"]) {
$selected = "selected='selected'";
if ($key == 'recordings') {
$playable = '../recordings/recordings.php?action=download&type=rec&filename='.$row["value"];
if ($key == 'recordings') {
if (
!empty($instance_value) &&
($instance_value == $row["value"] || $instance_value == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.$row["value"]) &&
file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME))
) {
$selected = "selected='selected'";
$playable = '../recordings/recordings.php?action=download&type=rec&filename='.pathinfo($row["value"], PATHINFO_BASENAME);
$found = true;
}
else if ($key == 'sounds') {
else {
unset($selected);
}
}
else if ($key == 'sounds') {
if (!empty($instance_value) && $instance_value == $row["value"]) {
$selected = "selected='selected'";
$playable = '../switch/sounds.php?action=download&filename='.$row["value"];
$found = true;
}
else {
unset($selected);
}
$found = true;
}
else {
unset($selected);
@ -667,15 +681,29 @@
foreach ($audio_files as $key => $value) {
echo "<optgroup label=".$text['label-'.$key]." data-type='".$key."'>\n";
foreach ($value as $row) {
if (!empty($instance_value) && $instance_value == $row["value"]) {
$selected = "selected='selected'";
if ($key == 'recordings') {
$playable = '../recordings/recordings.php?action=download&type=rec&filename='.$row["value"];
if ($key == 'recordings') {
if (
!empty($instance_value) &&
($instance_value == $row["value"] || $instance_value == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.$row["value"]) &&
file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME))
) {
$selected = "selected='selected'";
$playable = '../recordings/recordings.php?action=download&type=rec&filename='.pathinfo($row["value"], PATHINFO_BASENAME);
$found = true;
}
else if ($key == 'sounds') {
else {
unset($selected);
}
}
else if ($key == 'sounds') {
if (!empty($instance_value) && $instance_value == $row["value"]) {
$selected = "selected='selected'";
$playable = '../switch/sounds.php?action=download&filename='.$row["value"];
$found = true;
}
else {
unset($selected);
}
$found = true;
}
else {
unset($selected);
@ -693,7 +721,7 @@
if (if_group("superadmin")) {
echo "<input type='button' id='btn_select_to_input_".$instance_id."' class='btn' name='' alt='back' onclick='toggle_select_input(document.getElementById(\"".$instance_id."\"), \"".$instance_id."\"); this.style.visibility=\"hidden\";' value='&#9665;'>";
}
if ((permission_exists('recording_play') || permission_exists('recording_download')) && !empty($playable)) {
if ((permission_exists('recording_play') || permission_exists('recording_download')) && (!empty($playable) || empty($instance_value))) {
switch (pathinfo($playable, PATHINFO_EXTENSION)) {
case 'wav' : $mime_type = 'audio/wav'; break;
case 'mp3' : $mime_type = 'audio/mpeg'; break;