Installation
This guide will help you install and configure the Angular YouTube Player component.Install the Package
The easiest way to install is using Angular CLI:Import the Component
Standalone Components
For standalone components, importYouTubePlayer:
NgModule
For NgModule-based apps, importYouTubePlayerModule:
Load the YouTube API (Optional)
The component will automatically load the YouTube iframe API when needed. However, if you want to preload it, add this script to yourindex.html:
Verify Installation
Create a simple player to verify everything is working:Global Configuration
You can configure default behavior globally using theYOUTUBE_PLAYER_CONFIG injection token:
TypeScript Types
The YouTube Player uses types from the YouTube iframe API. You may want to install the types:Troubleshooting
Video Not Loading
- Check Video ID: Ensure the video ID is correct
- Check Console: Look for errors in the browser console
- Check Embedding: Some videos have embedding disabled
- Check Privacy: Age-restricted videos may not load
API Not Loading
If the YouTube API fails to load:- Check Network: Ensure you have internet connectivity
- Check Blockers: Ad blockers may prevent the API from loading
- Check CSP: Content Security Policy may block the script
- Manual Load: Try manually loading the API in
index.html
Next Steps
- Learn about the YouTube Player API
- Explore player configuration options
- Add event handlers for player events