Added video progress bar
This commit is contained in:
parent
de70254ce7
commit
3502fdaf8d
@ -17,7 +17,10 @@ component AMVVideo(amv *arn.AMV)
|
|||||||
//- RawIcon("play")
|
//- RawIcon("play")
|
||||||
|
|
||||||
.video-controls
|
.video-controls
|
||||||
.video-duration= fmt.Sprintf("%d:%02d", int(amv.Info.Duration.Minutes()), int(amv.Info.Duration.Seconds()) % 60)
|
.video-progress-bar
|
||||||
|
.video-current-progress
|
||||||
|
|
||||||
|
.video-time= fmt.Sprintf("%d:%02d", int(amv.Info.Duration.Minutes()), int(amv.Info.Duration.Seconds()) % 60)
|
||||||
|
|
||||||
//- button.video-control.action(data-action="like", data-trigger="click")
|
//- button.video-control.action(data-action="like", data-trigger="click")
|
||||||
//- RawIcon("heart-o")
|
//- RawIcon("heart-o")
|
||||||
|
@ -9,10 +9,30 @@ export function playVideo(arn: AnimeNotifier, video: HTMLVideoElement) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
video.addEventListener("loadeddata", () => {
|
video.addEventListener("canplay", () => {
|
||||||
togglePlayVideo(video)
|
togglePlayVideo(video)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let progressElement = video.parentElement.getElementsByClassName("video-current-progress")[0] as HTMLElement
|
||||||
|
let timeElement = video.parentElement.getElementsByClassName("video-time")[0]
|
||||||
|
|
||||||
|
video.addEventListener("timeupdate", () => {
|
||||||
|
let time = video.currentTime
|
||||||
|
let minutes = Math.trunc(time / 60)
|
||||||
|
let seconds = Math.trunc(time) % 60
|
||||||
|
let paddedSeconds = ("00" + seconds).slice(-2)
|
||||||
|
timeElement.textContent = `${minutes}:${paddedSeconds}`
|
||||||
|
progressElement.style.transform = `scaleX(${time / video.duration})`
|
||||||
|
})
|
||||||
|
|
||||||
|
video.addEventListener("waiting", () => {
|
||||||
|
arn.statusMessage.showInfo("Buffering...", -1)
|
||||||
|
})
|
||||||
|
|
||||||
|
video.addEventListener("playing", () => {
|
||||||
|
arn.statusMessage.close()
|
||||||
|
})
|
||||||
|
|
||||||
video.load()
|
video.load()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,9 +23,11 @@ const video-control-color = rgba(255, 255, 255, 0.75)
|
|||||||
|
|
||||||
.video-controls
|
.video-controls
|
||||||
position absolute
|
position absolute
|
||||||
bottom 0.5rem
|
bottom 0
|
||||||
right 0.75rem
|
right 0
|
||||||
|
padding 0.5rem 0.75rem
|
||||||
opacity 0
|
opacity 0
|
||||||
|
width 100%
|
||||||
horizontal
|
horizontal
|
||||||
align-items center
|
align-items center
|
||||||
default-transition
|
default-transition
|
||||||
@ -33,8 +35,23 @@ const video-control-color = rgba(255, 255, 255, 0.75)
|
|||||||
:hover
|
:hover
|
||||||
opacity 1 !important
|
opacity 1 !important
|
||||||
|
|
||||||
.video-duration
|
.video-progress-bar
|
||||||
|
flex 1
|
||||||
|
height 5px
|
||||||
|
background rgba(255, 255, 255, 0.5)
|
||||||
|
border-radius ui-element-border-radius
|
||||||
|
overflow hidden
|
||||||
|
|
||||||
|
.video-current-progress
|
||||||
|
background rgba(255, 255, 255, 0.75)
|
||||||
|
width 100%
|
||||||
|
height 100%
|
||||||
|
transform scaleX(0)
|
||||||
|
transform-origin 0
|
||||||
|
|
||||||
|
.video-time
|
||||||
color video-control-color
|
color video-control-color
|
||||||
|
margin-left 0.5rem
|
||||||
|
|
||||||
.video-control
|
.video-control
|
||||||
background transparent !important
|
background transparent !important
|
||||||
|
Loading…
Reference in New Issue
Block a user