A Unity package for YouTube video playback with automatic tool management, supporting both streaming and download functionalities.
- Direct YouTube video playback from URLs
- Dual playback modes: streaming and download
- Automatic external tool downloading (yt-dlp & FFmpeg)
- Comprehensive playback controls (play, pause, seek, speed, volume)
- Intelligent URL caching with expiration management
- Cross-platform architecture (Windows, macOS, Linux)
- Unity UI Toolkit integration
- Modern async/await programming patterns
- Open Unity Package Manager (
Window > Package Manager) - Click the
+button and selectAdd package from git URL - Enter:
https://github.com/Ddemon26/TCS.YoutubePlayer.git
- Download the latest release from Releases
- Extract to your Unity project's
Assetsfolder - Unity will automatically import the package
- Unity Editor 2020.3 or newer
- Internet connection for automatic tool downloads on first use
- Windows (full support), macOS/Linux (planned)
- Add the prefab: Drag
Runtime/Prefabs/YoutubePlayer.prefabto your scene - Configure settings: Set download permissions in the Inspector
- Call
PlayVideo(url)to play a YouTube video
using TCS.YoutubePlayer;
public class VideoController : MonoBehaviour
{
[SerializeField] YoutubePlayer youtubePlayer;
void Start()
{
youtubePlayer.PlayVideo("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
}
}The system automatically downloads and manages external tools:
- yt-dlp.exe - Latest version from GitHub releases
- FFmpeg Essentials - From gyan.dev
Download Location: Assets/StreamingAssets/
StreamingAssets/
├── yt-dlp/Windows/yt-dlp.exe
└── ffmpeg/Windows/bin/ffmpeg.exe
For custom tool versions:
- Place executables at the expected paths in StreamingAssets
- Create/update
tool_versions.jsonto prevent re-downloads
| Platform | Status | Notes |
|---|---|---|
| Windows | Full Support | Automatic downloads available |
| macOS | Planned | Manual installation required |
| Linux | Planned | Manual installation required |
Some browsers, like Google Chrome and Microsoft Edge, may incorrectly flag yt-dlp.exe as malicious due to its nature as a command-line downloader. This is a false positive. If you encounter issues downloading the tools, using a different browser like Mozilla Firefox is recommended.
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Make your changes and commit:
git commit -m 'Add your feature' - Push to the branch:
git push origin feature/your-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.