[feature/frontend] Add player for audio files; use thumbnail for poster (#3099)

* [feature/frontend] Audio player for audio media types

* use video preview images for previews instead of video itself

* don't preload

* update tests for new zork status

* collapse media gallery into single row when small
This commit is contained in:
tobi
2024-07-15 11:47:57 +02:00
committed by GitHub
parent 16421f7576
commit 9efb11d848
26 changed files with 327 additions and 95 deletions

View File

@ -624,7 +624,7 @@ func (c *Converter) AttachmentToAPIAttachment(ctx context.Context, a *gtsmodel.M
Y: a.FileMeta.Focus.Y,
}
case gtsmodel.FileTypeVideo:
case gtsmodel.FileTypeVideo, gtsmodel.FileTypeAudio:
if i := a.FileMeta.Original.Duration; i != nil {
apiAttachment.Meta.Original.Duration = *i
}
@ -1062,14 +1062,36 @@ func (c *Converter) StatusToWebStatus(
webStatus.PollOptions = PollOptions
}
// Mark local.
webStatus.Local = *s.Local
// Set additional templating
// variables on media attachments.
for _, a := range webStatus.MediaAttachments {
a.Sensitive = webStatus.Sensitive
// Get gtsmodel attachments
// into a convenient map.
ogAttachments := make(
map[string]*gtsmodel.MediaAttachment,
len(s.Attachments),
)
for _, a := range s.Attachments {
ogAttachments[a.ID] = a
}
// Mark this as a local status.
webStatus.Local = *s.Local
// Convert each API attachment
// into a web attachment.
webStatus.MediaAttachments = make(
[]*apimodel.WebAttachment,
len(apiStatus.MediaAttachments),
)
for i, apiAttachment := range apiStatus.MediaAttachments {
ogAttachment := ogAttachments[apiAttachment.ID]
webStatus.MediaAttachments[i] = &apimodel.WebAttachment{
Attachment: apiAttachment,
Sensitive: apiStatus.Sensitive,
MIMEType: ogAttachment.File.ContentType,
}
}
return webStatus, nil
}