Simplify video rendering
This commit is contained in:
parent
47ed1a3ae8
commit
bc352cdb65
2 changed files with 22 additions and 20 deletions
|
@ -2,8 +2,8 @@
|
|||
@import '_mixins';
|
||||
|
||||
video {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
max-height: 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.gallery-video {
|
||||
|
@ -18,10 +18,13 @@ video {
|
|||
.video-container {
|
||||
max-height: 530px;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
img {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
max-height: 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,9 +66,7 @@ proc isPlaybackEnabled(prefs: Prefs; video: Video): bool =
|
|||
of m3u8, vmap: prefs.hlsPlayback
|
||||
|
||||
proc renderVideoDisabled(video: Video; path: string): VNode =
|
||||
buildHtml(tdiv):
|
||||
img(src=getSmallPic(video.thumb))
|
||||
tdiv(class="video-overlay"):
|
||||
buildHtml(tdiv(class="video-overlay")):
|
||||
case video.playbackType
|
||||
of mp4:
|
||||
p: text "mp4 playback disabled in preferences"
|
||||
|
@ -76,9 +74,7 @@ proc renderVideoDisabled(video: Video; path: string): VNode =
|
|||
buttonReferer "/enablehls", "Enable hls playback", path
|
||||
|
||||
proc renderVideoUnavailable(video: Video): VNode =
|
||||
buildHtml(tdiv):
|
||||
img(src=getSmallPic(video.thumb))
|
||||
tdiv(class="video-overlay"):
|
||||
buildHtml(tdiv(class="video-overlay")):
|
||||
case video.reason
|
||||
of "dmcaed":
|
||||
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 =
|
||||
if video.description.len > 0 or video.title.len > 0: " card-container"
|
||||
else: ""
|
||||
|
||||
buildHtml(tdiv(class="attachments card")):
|
||||
tdiv(class="gallery-video" & container):
|
||||
tdiv(class="attachment video-container"):
|
||||
let thumb = getSmallPic(video.thumb)
|
||||
if not video.available:
|
||||
img(src=thumb)
|
||||
renderVideoUnavailable(video)
|
||||
elif not prefs.isPlaybackEnabled(video):
|
||||
img(src=thumb)
|
||||
renderVideoDisabled(video, path)
|
||||
else:
|
||||
let vid = video.variants.filterIt(it.videoType == video.playbackType)
|
||||
|
|
Loading…
Reference in a new issue