|
| 1 | +<template> |
| 2 | + <div> |
| 3 | + <h1>Interactive Video Examples</h1> |
| 4 | + |
| 5 | + <h2>Scenario 1: Component Renders Its Own Container</h2> |
| 6 | + <p>This example does not provide a `targetElementId` prop. The `InteractiveVideo` component will generate its own unique ID and render a `div` for the player.</p> |
| 7 | + <InteractiveVideo |
| 8 | + videoUrl="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" |
| 9 | + :autoplay="false" |
| 10 | + :loop="false" |
| 11 | + :cues="exampleCues" |
| 12 | + @analytics-event="handleAnalyticsEvent" |
| 13 | + style="width: 600px; height: 337.5px; border: 1px solid blue;" |
| 14 | + /> |
| 15 | + |
| 16 | + <h2>Scenario 2: External Container Provided</h2> |
| 17 | + <p>This example provides a `targetElementId` prop (`my-custom-player-container`). The `InteractiveVideo` component will attach to the `div` with this ID, which is rendered externally.</p> |
| 18 | + <div id="my-custom-player-container" style="width: 600px; height: 337.5px; border: 1px solid green;"></div> |
| 19 | + <InteractiveVideo |
| 20 | + videoUrl="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" |
| 21 | + targetElementId="my-custom-player-container" |
| 22 | + :autoplay="false" |
| 23 | + :loop="false" |
| 24 | + @analytics-event="handleAnalyticsEvent" |
| 25 | + /> |
| 26 | + </div> |
| 27 | +</template> |
| 28 | + |
| 29 | +<script lang="ts"> |
| 30 | +import { defineComponent } from 'vue'; |
| 31 | +import InteractiveVideo from '../src'; // Adjust path as needed |
| 32 | +import { CuePoint } from '@interactive-video-labs/core'; |
| 33 | +
|
| 34 | +export default defineComponent({ |
| 35 | + name: 'ExampleInteractiveVideo', |
| 36 | + components: { |
| 37 | + InteractiveVideo, |
| 38 | + }, |
| 39 | + setup() { |
| 40 | + const handleAnalyticsEvent = (event: string, payload?: any) => { |
| 41 | + console.log(`Analytics Event: ${event}`, payload); |
| 42 | + }; |
| 43 | +
|
| 44 | + const exampleCues: CuePoint[] = [ |
| 45 | + { |
| 46 | + id: 'segmentChange', |
| 47 | + time: 10, |
| 48 | + label: 'Segment Change', |
| 49 | + payload: { |
| 50 | + interaction: { |
| 51 | + type: 'choice-video-segment-change', |
| 52 | + title: 'Choose your path', |
| 53 | + description: 'Select a video segment to jump to.', |
| 54 | + question: 'Where would you like to go?', |
| 55 | + options: [ |
| 56 | + { |
| 57 | + level: 'Segment A', |
| 58 | + video: 'https://interactive-video-labs.github.io/assets/sample-interaction-1.mp4' |
| 59 | + }, |
| 60 | + { |
| 61 | + level: 'Segment B', |
| 62 | + video: 'https://interactive-video-labs.github.io/assets/sample-interaction-2.mp4' |
| 63 | + } |
| 64 | + ] |
| 65 | + } |
| 66 | + } |
| 67 | + }, |
| 68 | + { |
| 69 | + id: 'intro', |
| 70 | + time: 2, |
| 71 | + label: 'Introduction', |
| 72 | + payload: { message: 'Welcome!' } |
| 73 | + }, |
| 74 | + ]; |
| 75 | +
|
| 76 | + return { |
| 77 | + handleAnalyticsEvent, |
| 78 | + exampleCues, |
| 79 | + }; |
| 80 | + }, |
| 81 | +}); |
| 82 | +</script> |
| 83 | + |
| 84 | +<style scoped> |
| 85 | +div { |
| 86 | + margin-bottom: 20px; |
| 87 | +} |
| 88 | +</style> |
0 commit comments