implemented audio/video in note content renderer + streaming API #886

This commit is contained in:
zadam
2021-04-17 22:35:47 +02:00
parent 1fdf889ccf
commit 79bb249f3b
6 changed files with 10251 additions and 25 deletions

View File

@@ -39,7 +39,7 @@ async function getRenderedContent(note, options = {}) {
.css("max-width", "100%")
);
}
else if (!options.tooltip && (type === 'file' || type === 'pdf')) {
else if (!options.tooltip && ['file', 'pdf', 'audio', 'video']) {
const $downloadButton = $('<button class="file-download btn btn-primary" type="button">Download</button>');
const $openButton = $('<button class="file-open btn btn-primary" type="button">Open</button>');
@@ -57,6 +57,22 @@ async function getRenderedContent(note, options = {}) {
$content.append($pdfPreview);
}
else if (type === 'audio') {
const $audioPreview = $('<audio controls></audio>')
.attr("src", openService.getUrlForDownload("api/notes/" + note.noteId + "/open"))
.attr("type", note.mime)
.css("width", "100%");
$content.append($audioPreview);
}
else if (type === 'video') {
const $videoPreview = $('<video controls></video>')
.attr("src", openService.getUrlForDownload("api/notes/" + note.noteId + "/open"))
.attr("type", note.mime)
.css("width", "100%");
$content.append($videoPreview);
}
$content.append(
$('<div style="display: flex; justify-content: space-evenly; margin-top: 5px;">')
@@ -110,6 +126,10 @@ function getRenderingType(note) {
if (type === 'file' && note.mime === 'application/pdf') {
type = 'pdf';
} else if (type === 'file' && note.mime.startsWith('audio/')) {
type = 'audio';
} else if (type === 'file' && note.mime.startsWith('video/')) {
type = 'video';
}
if (note.isProtected) {