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,36 +66,35 @@ 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)) case video.playbackType
tdiv(class="video-overlay"): of mp4:
case video.playbackType p: text "mp4 playback disabled in preferences"
of mp4: of m3u8, vmap:
p: text "mp4 playback disabled in preferences" buttonReferer "/enablehls", "Enable hls playback", path
of m3u8, vmap:
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)) case video.reason
tdiv(class="video-overlay"): of "dmcaed":
case video.reason p: text "This media has been disabled in response to a report by the copyright owner"
of "dmcaed": else:
p: text "This media has been disabled in response to a report by the copyright owner" p: text "This media is unavailable"
else:
p: text "This media is unavailable"
proc renderVideo*(video: Video; prefs: Prefs; path: string): VNode = 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)