diff --git a/frontend/src/components/VideoBlock.vue b/frontend/src/components/VideoBlock.vue index 618d8830..26e95218 100644 --- a/frontend/src/components/VideoBlock.vue +++ b/frontend/src/components/VideoBlock.vue @@ -169,7 +169,6 @@ const toggleFullscreen = () => { diff --git a/frontend/src/pages/LessonForm.vue b/frontend/src/pages/LessonForm.vue index d88e7a7d..44f9435a 100644 --- a/frontend/src/pages/LessonForm.vue +++ b/frontend/src/pages/LessonForm.vue @@ -92,6 +92,7 @@ import { inject, ref, onBeforeUnmount, + watch, } from 'vue' import { sessionStore } from '../stores/session' import EditorJS from '@editorjs/editorjs' @@ -133,6 +134,7 @@ onMounted(() => { editor.value = renderEditor('content') instructorEditor.value = renderEditor('instructor-notes') window.addEventListener('keydown', keyboardShortcut) + enablePlyr() }) const renderEditor = (holder) => { @@ -463,6 +465,37 @@ const showToast = (title, text, icon) => { }) } +const enablePlyr = () => { + setTimeout(() => { + const videoElement = document.getElementsByClassName('video-player') + if (videoElement.length === 0) return + + const src = document + .getElementsByClassName('video-player')[0] + .getAttribute('src') + if (src) { + let videoID = src.split('/').pop() + document + .getElementsByClassName('video-player')[0] + .setAttribute('data-plyr-embed-id', videoID) + } + new Plyr('.video-player', { + youtube: { + noCookie: true, + }, + controls: [ + 'play-large', + 'play', + 'progress', + 'current-time', + 'mute', + 'volume', + 'fullscreen', + ], + }) + }, 500) +} + const breadcrumbs = computed(() => { let crumbs = [ { diff --git a/frontend/src/utils/index.js b/frontend/src/utils/index.js index 1b57cd1e..2089a12b 100644 --- a/frontend/src/utils/index.js +++ b/frontend/src/utils/index.js @@ -200,16 +200,14 @@ export function getEditorTools() { youtube: { regex: /(?:https?:\/\/)?(?:www\.)?(?:(?:youtu\.be\/)|(?:youtube\.com)\/(?:v\/|u\/\w\/|embed\/|watch))(?:(?:\?v=)?([^#&?=]*))?((?:[?&]\w*=\w*)*)/, embedUrl: '<%= remote_id %>', - /* 'https://www.youtube.com/embed/<%= remote_id %>?origin=https://plyr.io&iv_load_policy=3&modestbranding=1&playsinline=1&showinfo=0&rel=0&enablejsapi=1' */ html: `
`, + /* 'https://www.youtube.com/embed/<%= remote_id %>?origin=https://plyr.io&iv_load_policy=3&modestbranding=1&playsinline=1&showinfo=0&rel=0&enablejsapi=1' */ + html: `
`, id: ([id]) => id, }, vimeo: { regex: /(?:http[s]?:\/\/)?(?:www\.)?vimeo\.com\/(\d+)/, - embedUrl: - 'https://player.vimeo.com/video/<%= remote_id %>', - html: ``, + embedUrl: '<%= remote_id %>', + html: `
`, id: ([id]) => id, }, codepen: true,