mirror of
https://github.com/zadam/trilium.git
synced 2025-11-13 00:35:50 +01:00
implemented audio/video in note content renderer + streaming API #886
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user