From 1f46665c7332fd0f090934b252a1715d99bb16c9 Mon Sep 17 00:00:00 2001 From: Yi Lei Feng Date: Tue, 1 Oct 2024 14:17:54 -0400 Subject: [PATCH 1/2] process video files from editor --- src/components/panels/video-panel.vue | 61 +++++++++++++++++++++------ 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/src/components/panels/video-panel.vue b/src/components/panels/video-panel.vue index 8169d494..c7890263 100644 --- a/src/components/panels/video-panel.vue +++ b/src/components/panels/video-panel.vue @@ -24,7 +24,7 @@ :poster="config.thumbnailUrl" controls > - + import type { PropType } from 'vue'; -import { onBeforeMount, onMounted, ref } from 'vue'; +import { onBeforeMount, onMounted, ref, getCurrentInstance } from 'vue'; +import { ConfigFileStructure, VideoPanel } from '@storylines/definitions'; import { useRoute } from 'vue-router'; import MarkdownIt from 'markdown-it'; -import { VideoPanel } from '@storylines/definitions'; - const md = new MarkdownIt({ html: true }); const route = useRoute(); @@ -89,12 +88,18 @@ const props = defineProps({ config: { type: Object as PropType, required: true + }, + configFileStructure: { + type: Object as PropType } }); const lang = ref('en'); const langs = ref>({ en: 'English', fr: 'French' }); +const videoBlobSrc = ref(''); +const captionsBlobSrc = ref(''); +const transcriptBlobSrc = ref(''); const fileType = ref(''); const expandTranscript = ref(false); @@ -112,20 +117,48 @@ onBeforeMount(() => { }); onMounted(() => { - // fetch and config transcript content and render with md - if (props.config.transcript) { - const ext = extensionType(props.config.transcript); - - fetch(props.config.transcript).then((res: Response) => { - res.text().then((content: string) => { - rawTranscript.value = content; - // can be HTML or MD format - transcriptContent.value = ext === 'md' ? md.render(rawTranscript.value) : rawTranscript.value; + if (props.configFileStructure) { + // get video file from config file structure + const assetSrc = `${props.config.src.substring(props.config.src.indexOf('/') + 1)}`; + const assetFile = extractBlobFile(assetSrc); + videoBlobSrc.value = assetFile ? assetFile : ''; + + // get captions file from config file structure + const captionsSrc = `${props.config.src.substring(props.config.src.indexOf('/') + 1)}`; + const captionsFile = extractBlobFile(captionsSrc); + videoBlobSrc.value = captionsFile ? captionsFile : ''; + + // get transcript file from config file structure + const transcriptSrc = `${props.config.src.substring(props.config.src.indexOf('/') + 1)}`; + const transcriptFile = extractBlobFile(transcriptSrc); + videoBlobSrc.value = transcriptFile ? transcriptFile : ''; + } else { + // fetch and config transcript content and render with md + if (props.config.transcript) { + const ext = extensionType(props.config.transcript); + + fetch(props.config.transcript).then((res: Response) => { + res.text().then((content: string) => { + rawTranscript.value = content; + // can be HTML or MD format + transcriptContent.value = ext === 'md' ? md.render(rawTranscript.value) : rawTranscript.value; + }); }); - }); + } } }); +const extractBlobFile = (src: string): string => { + const videoFile = props.configFileStructure?.zip.file(src); + if (videoFile) { + videoFile.async('blob').then((res: Blob) => { + return URL.createObjectURL(res); + }); + } + + return ''; +}; + const toggleTranscript = (): void => { expandTranscript.value = !expandTranscript.value; }; From 9d0f430d9cacfa9f6ff05e36e199ec26b78cc33e Mon Sep 17 00:00:00 2001 From: Yi Lei Feng Date: Fri, 25 Oct 2024 13:36:17 -0400 Subject: [PATCH 2/2] add support for handling uploaded video/captions/transcript files in editor preview --- package.json | 2 +- src/components/panels/video-panel.vue | 53 ++++++++++++++++----------- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index f1c81ca2..9d02e9cf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ramp-storylines_demo-scenarios-pcar", "description": "A user-configurable story product featuring interactive maps, charts and dynamic multimedia content alongside text.", - "version": "3.2.6", + "version": "3.2.7", "private": false, "license": "MIT", "repository": "https://github.com/ramp4-pcar4/story-ramp", diff --git a/src/components/panels/video-panel.vue b/src/components/panels/video-panel.vue index c7890263..79fd4796 100644 --- a/src/components/panels/video-panel.vue +++ b/src/components/panels/video-panel.vue @@ -19,16 +19,17 @@