1
0
Fork 0

Add proper audio preview support

This commit is contained in:
Ryan Fox 2021-03-07 03:31:09 +00:00
parent b393666593
commit a27709ccfd
Signed by: flewkey
GPG Key ID: 94F56ADFD848851E
3 changed files with 46 additions and 17 deletions

View File

@ -874,6 +874,11 @@ input.form-control[type=file] {
animation-duration: 0.1s;
}
audio.viewer-content {
min-height: 0;
width: 75%;
}
@keyframes zoom {
from { transform: scale(.9) }
to { transform: scale(1) }

View File

@ -35,24 +35,40 @@ attachmentPreview context sensitive attachments ({ url, preview_url } as attachm
attId =
"att" ++ attachment.id ++ context
previewUrl =
if preview_url == "" then
url
else
preview_url
media =
a
[ if nsfw then
class "attachment-image nsfw"
else
class "attachment-image"
, href url
, onClickWithPreventAndStop <|
ViewerEvent (OpenViewer attachments attachment)
]
[ img [ src <|
if preview_url == "" then
url
else
preview_url
case attachment.type_ of
"audio" ->
a
[ if nsfw then
class "attachment-image nsfw"
else
class "attachment-image"
]
[]
]
[ audio
[ controls True
, style [("width", "100%")]
]
[ source [ src url ] []
]
]
_ ->
a
[ if nsfw then
class "attachment-image nsfw"
else
class "attachment-image"
, href url
, onClickWithPreventAndStop <|
ViewerEvent (OpenViewer attachments attachment)
]
[ img [ src previewUrl ] [] ]
in
li [ class "attachment-entry" ] <|
if nsfw then
@ -61,7 +77,7 @@ attachmentPreview context sensitive attachments ({ url, preview_url } as attachm
[ text "Sensitive content"
, br [] []
, br [] []
, text "click to show image"
, text "click to show attachment"
]
, media
]

View File

@ -37,12 +37,20 @@ viewerView ({ attachments, attachment } as viewer) =
"image" ->
img [ class "viewer-content", src attachment.url ] []
"audio" ->
audio
[ class "viewer-content"
, controls True
]
[ source [ src attachment.url ] [] ]
_ ->
video
[ class "viewer-content"
, preload "auto"
, autoplay True
, loop True
, controls True
]
[ source [ src attachment.url ] [] ]
, navLink "" "next" next <| ViewerEvent NextAttachment