VideoSourceConfiguration class
Configuration object used to initialize video playback.
Depending on the videoSourceType, provide exactly one of:
- videoUrl → for YouTube or network videos.
- videoId → for Vimeo videos.
- videoDataSource → for asset or local file videos.
⚠️ Rules:
- Provide only one of videoUrl, videoId, or videoDataSource.
- videoId is only valid for Vimeo.
- videoUrl is valid for YouTube and network streams.
- videoDataSource is valid for assets or local files.
Factory Constructors:
Vimeo
VideoSourceConfiguration.vimeo(
videoId: "123456789",
)
YouTube
VideoSourceConfiguration.youtube(
videoUrl: Uri.parse("https://www.youtube.com/watch?v=dQw4w9WgXcQ"),
)
Network
VideoSourceConfiguration.network(
videoUrl: Uri.parse("https://example.com/video.mp4"),
)
Asset
VideoSourceConfiguration.asset(
videoDataSource: 'assets/videos/video.mp4',
)
Common playback options (modifiable with copyWith):
- autoPlay: Whether playback should start automatically (default: false).
- initialPosition: The initial playback position (default: Duration.zero).
- initialVolume: Initial volume level between 0.0 and 1.0 (default: 1.0).
- initialPlaybackSpeed: The initial playback speed for the video (default: 1.0).
- autoMuteOnStart: Whether playback should start muted (default: false).
- preferredQualities: Preferred video quality levels (default: OmniVideoQuality.medium480).
- allowSeeking: Whether seeking is allowed (default: true).
- timeoutDuration: Maximum wait time before considering playback failed (default: 30 seconds).
- Annotations
Constructors
- VideoSourceConfiguration.asset({required String videoDataSource})
-
Factory constructor for asset or local file videos.
factory
- VideoSourceConfiguration.file({required File videoFile})
-
Factory constructor for file videos.
factory
-
VideoSourceConfiguration.network({required Uri videoUrl, List<
OmniVideoQuality> preferredQualities = const [OmniVideoQuality.medium480], List<OmniVideoQuality> ? availableQualities}) -
Factory constructor for network videos.
factory
-
VideoSourceConfiguration.vimeo({required String videoId, List<
OmniVideoQuality> preferredQualities = const [OmniVideoQuality.medium480]}) -
Factory constructor for Vimeo videos.
factory
-
VideoSourceConfiguration.youtube({required Uri videoUrl, List<
OmniVideoQuality> preferredQualities = const [OmniVideoQuality.medium480], List<OmniVideoQuality> ? availableQualities, bool enableYoutubeWebViewFallback = true, bool forceYoutubeWebViewOnly = false}) -
Factory constructor for YouTube videos.
factory
Properties
- allowSeeking → bool
-
Whether the user is allowed to seek the video.
final
- autoMuteOnStart → bool
-
Whether playback should start muted.
final
- autoPlay → bool
-
Whether playback should start automatically.
final
-
availablePlaybackSpeed
→ List<
double> -
List of available playback speeds for the user to select from.
final
-
availableQualities
→ List<
OmniVideoQuality> ? -
The list of available video qualities for this video.
final
- enableYoutubeWebViewFallback → bool
-
Whether to automatically fallback to a WebView-based YouTube player
if native playback initialization fails.
final
- forceYoutubeWebViewOnly → bool
-
Forces the use of the WebView player for YouTube, skipping native stream initialization.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- initialPlaybackSpeed → double
-
The initial playback speed for the video.
final
- initialPosition → Duration
-
The initial playback position.
final
- initialVolume → double
-
Initial volume level (range 0.0 to 1.0).
final
-
preferredQualities
→ List<
OmniVideoQuality> -
Preferred video quality levels in order of preference.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- synchronizeMuteAcrossPlayers → bool
-
Synchronizes the mute state across all video players controlled globally.
final
- timeoutDuration → Duration
-
Maximum wait time before considering playback failed.
final
- videoDataSource → String?
-
The asset or file path (for asset or local file videos).
final
- videoFile → File?
-
The file
final
- videoId → String?
-
The video ID (only for Vimeo videos).
final
- videoSourceType → VideoSourceType
-
Defines the source type, must match the appropriate data source field.
final
- videoUrl → Uri?
-
The video URL (for YouTube or network-based videos).
final
Methods
-
copyWith(
{bool? autoPlay, Duration? initialPosition, double? initialVolume, double? initialPlaybackSpeed, List< double> ? availablePlaybackSpeed, bool? autoMuteOnStart, bool? allowSeeking, bool? synchronizeMuteAcrossPlayers, Duration? timeoutDuration, List<OmniVideoQuality> ? preferredQualities, List<OmniVideoQuality> ? availableQualities, bool? enableYoutubeWebViewFallback, bool? forceYoutubeWebViewOnly}) → VideoSourceConfiguration - Returns a new instance of VideoSourceConfiguration with updated common playback fields.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited