MCPcopy Create free account
hub / github.com/Moebytes/Frame-Player / updateABloop

Function updateABloop

components/VideoPlayer.tsx:1118–1150  ·  view source on GitHub ↗
(value: number[])

Source from the content-addressed store, hash-verified

1116 }
1117
1118 const updateABloop = (value: number[]) => {
1119 const loopStart = value[0]
1120 const loopEnd = value[1]
1121 const current = videoRef.current ? videoRef.current.currentTime : progress
1122 const duration = getDuration()
1123
1124 let start = reverse ? (duration / 100) * (100 - loopStart)
1125 : (duration / 100) * loopStart
1126
1127 let end = reverse ? (duration / 100) * (100 - loopEnd)
1128 : (duration / 100) * loopEnd
1129
1130 if (videoData && videoRef.current) {
1131 start = duration - start
1132 end = duration - end
1133 }
1134
1135 if (reverse) {
1136 if (current > start || current < end) {
1137 if (videoRef.current) videoRef.current.currentTime = end
1138 setProgress(end)
1139 setSeekTo(end)
1140 }
1141 } else {
1142 if (current < start || current > end) {
1143 if (videoRef.current) videoRef.current.currentTime = start
1144 setProgress(start)
1145 setSeekTo(start)
1146 }
1147 }
1148 setDragging(false)
1149 setABDragging(false)
1150 }
1151
1152 const toggleAB = (value?: boolean) => {
1153 const currentABloop = value !== undefined ? value : !abloop

Callers 2

pasteLoopFunction · 0.85
VideoPlayerFunction · 0.85

Calls 1

getDurationFunction · 0.85

Tested by

no test coverage detected