一个 Flutter 包,可实现 YouTube 视频在应用程序中的无缝嵌入,并提供可自定义的播放选项。它支持 Android、iOS、macOS 和 Windows 等多个平台,为开发者提供了灵活集成视频内容的方式。该包提供了一个简单的 API 来加载和控制视频,包括自动播放、循环播放和自定义控件等功能。非常适合需要丰富媒体体验的应用程序,例如教育平台、视频教程或娱乐应用。
适合场景
在移动和桌面应用程序中嵌入 YouTube 视频
创建视频教程界面
构建丰富的媒体教育资源
将视频流集成到社交应用中
开发流媒体或娱乐平台
主要特点
跨平台支持(Android、iOS、macOS、Windows)
可自定义的播放器控件
自动播放和循环选项
响应式视频尺寸
与 Flutter UI 的轻松集成
适合对象
教育类应用程序开发者
媒体和娱乐应用
内容创作者
需要视频集成的应用程序构建者
Flutter 初学者探索媒体功能
使用建议
需要互联网连接以加载视频
可能需要为自定义主题添加额外的样式
仅限YouTube视频网址
多个播放器可能带来的性能影响
依赖于 YouTube 嵌入 API 的稳定性
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
youtube_player_embed
youtube_player_embed is a lightweight and customizable Flutter package that allows developers to embed YouTube videos, including YouTube Shorts, directly into their Flutter applications using an InAppWebView. With this package, you can seamlessly integrate videos with advanced event handling, autoplay, mute, and aspect ratio customization.
Features
🎥 Embed YouTube Videos and Shorts easily with minimal configuration.
🔄 Autoplay Support for instant video playback.
🔇 Mute Option for silent playback.
📱 Responsive Design supporting both horizontal (16:9) and vertical (9:16) videos.
💡 Customizable options to remove YouTube branding buttons for a cleaner UI.
🔗 Direct Shorts Integration for embedding vertical YouTube Shorts seamlessly.
⏰ Advanced Event Listeners for video state updates, time tracking, seek events, and mute/unmute detection.
🔑 Enhanced Control to programmatically remove share and branding buttons dynamically.
⏯ Full-Screen Support with seamless entry and exit.
⏹️ Playback Controls: Play, Pause, Seek, Mute, and Unmute programmatically.
🔍 Custom Video Titles: Dynamically set or hide video titles.
🚀 Performance Optimized: Lightweight and efficient for a smoother user experience.
Installation
Add the following dependency to your pubspec.yaml:
If you still have this problem, try to edit iOS Podfile like this
Edit the Podfile
Add the following to your iOS Podfile if you encounter issues:
target 'Runner' do
use_frameworks! # required by flutter_inappwebview
...
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '5.0' # required by flutter_inappwebview
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end