Overview
Platzi Viewer features a custom video player with advanced streaming capabilities, adaptive synchronization, and compatibility modes to ensure smooth playback of course videos streamed directly from Google Drive.Video Player Features
YouTube-Style Custom Controls
The player uses custom controls for a consistent experience across browsers:- Play/Pause Button - Toggle video playback
- Progress Bar - Seek to any point in the video
- Volume Control - Slider and mute button
- Playback Speed - Cycle through speeds (0.5x, 0.75x, 1x, 1.25x, 1.5x, 2x)
- Quality Selector - Choose video quality (if available)
- Subtitles (CC) - Toggle Spanish subtitles when available
- Fullscreen Toggle - Enter/exit fullscreen mode
- External Player - Open video in VLC or another external player
Player Controls Bar
Video Overlay
Floating controls at the top of the video:- Open External Player - Launch VLC or default video player
- Download Video - Download video file directly
- Previous Class - Navigate to previous video
- Next Class - Navigate to next video
Streaming from Google Drive
How It Works
All video content streams directly from Google Drive through a backend proxy:- No videos stored locally on the server
- Streams on-demand using Google Drive file IDs
- Supports HTTP Range Requests for seeking and buffering
- Transparent proxy with automatic authentication
HTTP Range Requests
The player uses Range Requests for efficient streaming:- Partial Content: Browser requests specific byte ranges (HTTP 206)
- Efficient Seeking: Jump to any point without downloading entire file
- Buffer Control: Download only what’s needed for smooth playback
- Bandwidth Optimization: Reduces data transfer for seeking/skipping
Streaming URLs
Video URLs are generated dynamically:- File metadata retrieval from Drive
- MIME type detection (fallback by extension)
- Range request processing
- Chunked streaming (1MB chunks)
Adaptive A/V Synchronization
Sync Monitoring
The player includes advanced audio/video synchronization: Frame-Based Monitoring:- Uses
requestVideoFrameCallbackAPI when available - Monitors drift between
currentTimeandmediaTime - Samples every 700ms to detect desynchronization
- Tracks dropped video frames via
getVideoPlaybackQuality() - Monitors frame drop ratio every 3 seconds
- Triggers corrective actions on sustained drops
Automatic Corrections
Soft Resync:- Triggered on moderate drift (≥0.28s for 4+ samples)
- Seeks back 0.03 seconds to realign
- Cooldown: 9 seconds between corrections
- Triggered on severe drift (≥0.42s for 6+ samples)
- Seeks back 0.08 seconds for stronger correction
- Cooldown: 12 seconds between corrections
- Recorded for diagnostics
- Triggered on severe frame drops (≥20% drop ratio)
- Automatically lowers video quality if in auto mode
- Prevents further A/V desynchronization
- Cooldown: 7 seconds between quality changes
Sync Statistics
The player tracks detailed synchronization metrics:Compatibility Mode
When to Use Compatibility Mode
Some videos may have corrupt timestamps or codec issues that cause persistent desynchronization. Compatibility mode uses FFmpeg to fix these issues. Automatic Activation: Compatibility mode activates automatically after 3 hard resyncs within 2 minutes. Manual Activation: Click “Modo compat.” button when the sync prompt appears.How It Works
FFmpeg Processing: The backend re-processes the video stream:- Copy mode - Fast remuxing to fix container issues
- Transcode mode - Full re-encode for severe corruption (if
PLATZI_COMPAT_FORCE_REENCODE=1)
- Streams while processing (no pre-download wait)
- Automatically selects best codec profile
- Preserves original quality when possible
- Falls back to normal mode on error
Compatibility Prompt
When sync issues are detected, a prompt appears:- Modo compat. - Enable FFmpeg compatibility mode
- Abrir VLC - Open video in VLC media player
- Siempre - Always open VLC for future sync issues
- × - Dismiss for this class
Quality Selection
Auto Quality
By default, the player selects optimal quality based on:- Network Speed: Connection type (2G, 3G, 4G, etc.)
- Viewport Size: Screen resolution (480p, 720p, 1080p)
- Data Saver: Honors browser/OS data saving preferences
- 2G/Slow-2G: 360p
- 3G: 480p
- Viewport ≤800px: 480p
- Viewport ≥1200px: 1080p
- Default: 720p
Manual Quality Selection
Override auto quality:- Click the Quality button in player controls
- Select from available qualities:
- Auto (recommended)
- 1080p
- 720p
- 480p
- 360p
- Original
- Player switches quality while maintaining playback position
Quality Switching
Seamless Switching:- Remembers current playback position
- Pauses briefly to load new quality
- Resumes automatically at same timestamp
- Minimum 7-second interval between switches
Playback Speed Control
Available Speeds
Cycle through speeds by clicking the Speed button:- 0.5x (half speed)
- 0.75x (slow)
- 1x (normal) - default
- 1.25x (fast)
- 1.5x (faster)
- 2x (double speed)
Speed Override Detection
The player detects manual speed changes and:- Disables automatic A/V sync corrections
- Prevents auto-quality adjustments
- Allows you to watch at custom speeds without interference
Subtitles
Subtitle Support
When available, subtitles are provided in WebVTT format:- Format:
.vttfiles served from Google Drive - Language: Spanish (es)
- Default: Off (toggle manually)
Enabling Subtitles
- Click the CC button in player controls
- Subtitles toggle on/off
- Button highlights when active: CC
Buffering and Seek
Buffer Visualization
The progress bar shows:- Gray bar - Unbuffered portion
- White segments - Buffered ranges
- Red bar - Played portion
- Circular thumb - Current position
Seeking
Mouse/Touch:- Click or drag on the progress bar
- Preview position updates while dragging
- Release to seek to new position
←- Seek backward 5 seconds→- Seek forward 5 seconds
- Pauses video during seek
- Resumes automatically if playing
- Uses optimized sync-aware seeking
Buffer Management
The player monitors buffer health:- Minimum 0.25s buffer before starting playback
- Soft resync requires 0.3s buffer ahead
- Auto-downshift requires 0.35s buffer
- Adaptive buffering based on network speed
External Player Integration
Opening in VLC
For problematic videos or offline viewing:- Click External Player button in overlay or controls
- Video URL is copied to clipboard automatically
- VLC (or system default) opens with the stream
- Desktop:
vlc://protocol handler - Android: Intent-based VLC launch
- iOS:
vlc-x-callback://URL scheme - Fallback: Opens URL in new tab
Download Video
Click the Download button in the video overlay to download the video file directly from Google Drive. Note: Large files may take time to download depending on your connection.Fullscreen Mode
Entering Fullscreen
Methods:- Click the Fullscreen button
- Press
Fkey - Double-click the video
Exiting Fullscreen
Methods:- Click the Exit Fullscreen button
- Press
Escapekey - Press
Fkey again
- Controls auto-hide after 2.5 seconds
- Mouse movement shows controls temporarily
- Works on video wrapper (includes controls)
Advanced Features
Touch Device Optimization
Adaptive Interface:- Larger tap targets for buttons
- Touch-friendly controls layout
- Optimized sidebar behavior
- Prevents accidental interactions
Mouse UI Auto-Hide
Desktop Behavior:- Controls appear on mouse movement
- Auto-hide after 2.5 seconds during playback
- Always visible when paused
- Overlay fades independently
Clean Navigation
When navigating away from player:- Video stops automatically
- Source is removed to prevent background audio
- Fullscreen exits cleanly
- Resources are freed properly
Diagnostics and Troubleshooting
Health Check
Check server and streaming health:- Drive API availability
- FFmpeg availability
- Compatibility mode statistics
- Recent streaming performance
Console Diagnostics
View detailed playback information:Common Issues
Video Won’t Play:- Check
/api/healthendpoint - Verify Google Drive access
- Check browser console for errors
- Enable compatibility mode manually
- Try opening in VLC
- Check compatibility health snapshot
- Lower video quality manually
- Check network connection
- Verify buffer ahead time
- Ensure CC button is clicked (highlighted)
- Check that
.vttfile exists for the class - Check browser console for subtitle loading errors
Best Practices
- Let Auto-Sync Work: Avoid manual seeking during initial buffer
- Use Compatibility Mode: For videos with repeated sync issues
- Quality Selection: Use auto mode for best experience
- Network Issues: Lower quality manually if buffering persists
- Long Sessions: Sync corrections may increase over time (normal behavior)
- External Players: Use VLC for maximum compatibility with problematic files