fix: allow backward seek but prevent forward seek
This commit is contained in:
@@ -74,7 +74,6 @@
|
|||||||
v-model="currentTime"
|
v-model="currentTime"
|
||||||
@input="changeCurrentTime"
|
@input="changeCurrentTime"
|
||||||
class="duration-slider h-1"
|
class="duration-slider h-1"
|
||||||
:disabled="preventSkippingVideos.data"
|
|
||||||
/>
|
/>
|
||||||
<!-- QUIZ MARKERS -->
|
<!-- QUIZ MARKERS -->
|
||||||
<div class="absolute top-0 left-0 w-full h-full pointer-events-none">
|
<div class="absolute top-0 left-0 w-full h-full pointer-events-none">
|
||||||
@@ -299,6 +298,11 @@ const toggleMute = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const changeCurrentTime = () => {
|
const changeCurrentTime = () => {
|
||||||
|
if (
|
||||||
|
preventSkippingVideos.data &&
|
||||||
|
currentTime.value > videoRef.value.currentTime
|
||||||
|
)
|
||||||
|
return
|
||||||
videoRef.value.currentTime = currentTime.value
|
videoRef.value.currentTime = currentTime.value
|
||||||
updateNextQuiz()
|
updateNextQuiz()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -511,6 +511,7 @@ const getVideoDetails = () => {
|
|||||||
const videos = document.querySelectorAll('video')
|
const videos = document.querySelectorAll('video')
|
||||||
if (videos.length > 0) {
|
if (videos.length > 0) {
|
||||||
videos.forEach((video) => {
|
videos.forEach((video) => {
|
||||||
|
if (video.currentTime == video.duration) markProgress()
|
||||||
details.push({
|
details.push({
|
||||||
source: video.src,
|
source: video.src,
|
||||||
watch_time: video.currentTime,
|
watch_time: video.currentTime,
|
||||||
@@ -523,6 +524,7 @@ const getVideoDetails = () => {
|
|||||||
const getPlyrSourceDetails = () => {
|
const getPlyrSourceDetails = () => {
|
||||||
let details = []
|
let details = []
|
||||||
plyrSources.value.forEach((source) => {
|
plyrSources.value.forEach((source) => {
|
||||||
|
if (source.currentTime == source.duration) markProgress()
|
||||||
let src = cleanYouTubeUrl(source.source)
|
let src = cleanYouTubeUrl(source.source)
|
||||||
details.push({
|
details.push({
|
||||||
source: src,
|
source: src,
|
||||||
@@ -544,6 +546,7 @@ watch(
|
|||||||
async (data) => {
|
async (data) => {
|
||||||
setupLesson(data)
|
setupLesson(data)
|
||||||
getPlyrSource()
|
getPlyrSource()
|
||||||
|
if (data.icon == 'icon-youtube') clearInterval(timerInterval)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -551,7 +554,6 @@ const getPlyrSource = async () => {
|
|||||||
await nextTick()
|
await nextTick()
|
||||||
if (plyrSources.value.length == 0) {
|
if (plyrSources.value.length == 0) {
|
||||||
plyrSources.value = await enablePlyr()
|
plyrSources.value = await enablePlyr()
|
||||||
console.log(plyrSources.value)
|
|
||||||
}
|
}
|
||||||
updateVideoWatchDuration()
|
updateVideoWatchDuration()
|
||||||
}
|
}
|
||||||
@@ -570,6 +572,9 @@ const updateVideoWatchDuration = () => {
|
|||||||
|
|
||||||
const updatePlyrVideoTime = (video) => {
|
const updatePlyrVideoTime = (video) => {
|
||||||
plyrSources.value.forEach((plyrSource) => {
|
plyrSources.value.forEach((plyrSource) => {
|
||||||
|
let lastWatchedTime = 0
|
||||||
|
let isSeeking = false
|
||||||
|
|
||||||
plyrSource.on('ready', () => {
|
plyrSource.on('ready', () => {
|
||||||
if (plyrSource.source === video.source) {
|
if (plyrSource.source === video.source) {
|
||||||
plyrSource.embed.seekTo(video.watch_time, true)
|
plyrSource.embed.seekTo(video.watch_time, true)
|
||||||
|
|||||||
@@ -566,18 +566,39 @@ const setupPlyrForVideo = (video, players) => {
|
|||||||
'fullscreen',
|
'fullscreen',
|
||||||
]
|
]
|
||||||
|
|
||||||
if (useSettings().preventSkippingVideos.data) {
|
|
||||||
controls.splice(controls.indexOf('progress'), 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
const player = new Plyr(video, {
|
const player = new Plyr(video, {
|
||||||
youtube: { noCookie: true },
|
youtube: { noCookie: true },
|
||||||
controls: controls,
|
controls: controls,
|
||||||
|
listeners: {
|
||||||
|
seek: function customSeekBehavior(e) {
|
||||||
|
const current_time = player.currentTime
|
||||||
|
const newTime = getTargetTime(player, e)
|
||||||
|
if (
|
||||||
|
useSettings().preventSkippingVideos.data &&
|
||||||
|
parseFloat(newTime) > current_time
|
||||||
|
) {
|
||||||
|
e.preventDefault()
|
||||||
|
player.currentTime = current_time
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
players.push(player)
|
players.push(player)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getTargetTime = (plyr, input) => {
|
||||||
|
if (
|
||||||
|
typeof input === 'object' &&
|
||||||
|
(input.type === 'input' || input.type === 'change')
|
||||||
|
) {
|
||||||
|
return (input.target.value / input.target.max) * plyr.duration
|
||||||
|
} else {
|
||||||
|
return Number(input)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const extractYouTubeId = (url) => {
|
const extractYouTubeId = (url) => {
|
||||||
try {
|
try {
|
||||||
const parsedUrl = new URL(url)
|
const parsedUrl = new URL(url)
|
||||||
|
|||||||
@@ -1320,6 +1320,7 @@ def get_lesson(course, chapter, lesson):
|
|||||||
lesson_details.progress = progress
|
lesson_details.progress = progress
|
||||||
lesson_details.prev = neighbours["prev"]
|
lesson_details.prev = neighbours["prev"]
|
||||||
lesson_details.membership = membership
|
lesson_details.membership = membership
|
||||||
|
lesson_details.icon = get_lesson_icon(lesson_details.body, lesson_details.content)
|
||||||
lesson_details.instructors = get_instructors("LMS Course", course)
|
lesson_details.instructors = get_instructors("LMS Course", course)
|
||||||
lesson_details.course_title = course_info.title
|
lesson_details.course_title = course_info.title
|
||||||
lesson_details.paid_certificate = course_info.paid_certificate
|
lesson_details.paid_certificate = course_info.paid_certificate
|
||||||
|
|||||||
Reference in New Issue
Block a user