Title: Visual Narration with Dream Scenario and WebVTT
Description:
Inspired by Nicolas Cage’s surreal and introspective role in Dream Scenario, this project uses the WebVTT (Web Video Text Tracks) format to create a web application that provides visual narration and subtitles for a video. The application captures the dreamlike and narrative-rich atmosphere of the film, enabling users to watch a video with dynamically displayed captions and descriptions. This project demonstrates the practical use of WebVTT to enhance video content with synchronized text tracks, reflecting the film’s themes of introspection and storytelling.
Features:
- Dynamic Subtitles: Use WebVTT to display synchronized subtitles and descriptions for a video.
- Interactive Controls: Provide controls for users to play, pause, and seek through the video.
- Thematic Design: Reflect the surreal and narrative-rich atmosphere of Dream Scenario through the application’s design and interactions.
Starting Code:
Beginner Hints:
- Create a single
index.htmlfile. - Copy the full HTML code block into that file.
- Open
index.htmlin your browser. If something doesn’t work, try a local server likepython -m http.server. - Open DevTools Console to spot errors and typos quickly.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Visual Narration with Dream Scenario and WebVTT</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #121212;
color: #f0f0f0;
text-align: center;
padding: 50px;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #1d1d1d;
border: 1px solid #444;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}
h1 {
margin-bottom: 20px;
color: #ff6347;
}
video {
width: 100%;
border-radius: 10px;
margin-bottom: 20px;
}
.controls {
margin-top: 20px;
}
</style>
</head>
<body>
<div class="container">
<h1>Visual Narration</h1>
<p>Watch the video with subtitles inspired by Dream Scenario.</p>
<video id="video" controls>
<source src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4" type="video/mp4">
<track id="subtitles" label="English" kind="subtitles" srclang="en" default>
Your browser does not support the video tag.
</video>
<div class="controls">
<button onclick="document.getElementById('video').play()">Play</button>
<button onclick="document.getElementById('video').pause()">Pause</button>
<button onclick="document.getElementById('video').currentTime -= 10">Rewind 10s</button>
<button onclick="document.getElementById('video').currentTime += 10">Forward 10s</button>
</div>
</div>
<script>
const vtt = `WEBVTT
00:00:00.000 --> 00:00:05.000
[Narrator] Welcome to the dream scenario.
00:00:05.001 --> 00:00:10.000
[Narrator] In this world, reality and dreams blend seamlessly.
00:00:10.001 --> 00:00:15.000
[Narrator] Follow the journey and uncover the hidden truths.
00:00:15.001 --> 00:00:20.000
[Narrator] What you see might not be what it seems.`;
const track = document.getElementById('subtitles');
const vttBlob = new Blob([vtt.trim()], { type: 'text/vtt' });
track.src = URL.createObjectURL(vttBlob);
const video = document.getElementById('video');
video.addEventListener('play', () => {
console.log('Video started playing');
});
video.addEventListener('pause', () => {
console.log('Video paused');
});
video.addEventListener('seeked', () => {
console.log('Video seeked to ' + video.currentTime);
});
</script>
</body>
</html>
References:
Project Overview:
This project leverages WebVTT to create a dynamic and immersive video experience inspired by Dream Scenario. Users can watch a video with synchronized subtitles, providing an engaging and interactive viewing experience. The application demonstrates the practical use of WebVTT for enhancing video content with text tracks, reflecting the film’s themes of introspection and storytelling. Embrace the narrative depth and surrealism of Nicolas Cage’s character to master the use of WebVTT in web development. Praise Cage!