Simplify video rendering

This commit is contained in:
Zed 2022-01-03 03:27:04 +01:00
parent 47ed1a3ae8
commit bc352cdb65
2 changed files with 22 additions and 20 deletions

View File

@ -2,8 +2,8 @@
@import '_mixins'; @import '_mixins';
video { video {
height: 100%; max-height: 100%;
width: 100%; max-width: 100%;
} }
.gallery-video { .gallery-video {
@ -18,10 +18,13 @@ video {
.video-container { .video-container {
max-height: 530px; max-height: 530px;
margin: 0; margin: 0;
display: flex;
align-items: center;
justify-content: center;
img { img {
height: 100%; max-height: 100%;
width: 100%; max-width: 100%;
} }
} }

View File

@ -66,9 +66,7 @@ proc isPlaybackEnabled(prefs: Prefs; video: Video): bool =
of m3u8, vmap: prefs.hlsPlayback of m3u8, vmap: prefs.hlsPlayback
proc renderVideoDisabled(video: Video; path: string): VNode = proc renderVideoDisabled(video: Video; path: string): VNode =
buildHtml(tdiv): buildHtml(tdiv(class="video-overlay")):
img(src=getSmallPic(video.thumb))
tdiv(class="video-overlay"):
case video.playbackType case video.playbackType
of mp4: of mp4:
p: text "mp4 playback disabled in preferences" p: text "mp4 playback disabled in preferences"
@ -76,9 +74,7 @@ proc renderVideoDisabled(video: Video; path: string): VNode =
buttonReferer "/enablehls", "Enable hls playback", path buttonReferer "/enablehls", "Enable hls playback", path
proc renderVideoUnavailable(video: Video): VNode = proc renderVideoUnavailable(video: Video): VNode =
buildHtml(tdiv): buildHtml(tdiv(class="video-overlay")):
img(src=getSmallPic(video.thumb))
tdiv(class="video-overlay"):
case video.reason case video.reason
of "dmcaed": of "dmcaed":
p: text "This media has been disabled in response to a report by the copyright owner" p: text "This media has been disabled in response to a report by the copyright owner"
@ -89,13 +85,16 @@ proc renderVideo*(video: Video; prefs: Prefs; path: string): VNode =
let container = let container =
if video.description.len > 0 or video.title.len > 0: " card-container" if video.description.len > 0 or video.title.len > 0: " card-container"
else: "" else: ""
buildHtml(tdiv(class="attachments card")): buildHtml(tdiv(class="attachments card")):
tdiv(class="gallery-video" & container): tdiv(class="gallery-video" & container):
tdiv(class="attachment video-container"): tdiv(class="attachment video-container"):
let thumb = getSmallPic(video.thumb) let thumb = getSmallPic(video.thumb)
if not video.available: if not video.available:
img(src=thumb)
renderVideoUnavailable(video) renderVideoUnavailable(video)
elif not prefs.isPlaybackEnabled(video): elif not prefs.isPlaybackEnabled(video):
img(src=thumb)
renderVideoDisabled(video, path) renderVideoDisabled(video, path)
else: else:
let vid = video.variants.filterIt(it.videoType == video.playbackType) let vid = video.variants.filterIt(it.videoType == video.playbackType)