mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user