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; animation-duration: 0.1s;
} }
audio.viewer-content {
min-height: 0;
width: 75%;
}
@keyframes zoom { @keyframes zoom {
from { transform: scale(.9) } from { transform: scale(.9) }
to { transform: scale(1) } to { transform: scale(1) }

View File

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

View File

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