一個 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