copyWith method

VideoSourceConfiguration copyWith({
  1. bool? autoPlay,
  2. Duration? initialPosition,
  3. double? initialVolume,
  4. double? initialPlaybackSpeed,
  5. List<double>? availablePlaybackSpeed,
  6. bool? autoMuteOnStart,
  7. bool? allowSeeking,
  8. bool? synchronizeMuteAcrossPlayers,
  9. Duration? timeoutDuration,
  10. List<OmniVideoQuality>? preferredQualities,
  11. List<OmniVideoQuality>? availableQualities,
  12. bool? enableYoutubeWebViewFallback,
  13. bool? forceYoutubeWebViewOnly,
})

Returns a new instance of VideoSourceConfiguration with updated common playback fields.

The parameters that distinguish the video source (videoUrl, videoId, videoDataSource, videoSourceType) cannot be modified here to maintain consistency.

Implementation

VideoSourceConfiguration 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,
}) {
  final newPreferred = preferredQualities ?? this.preferredQualities;
  final newAvailable = availableQualities ?? this.availableQualities;

  _validatePreferredQualities(
    preferred: newPreferred,
    available: newAvailable,
  );

  return VideoSourceConfiguration._(
    videoUrl: videoUrl,
    videoId: videoId,
    videoDataSource: videoDataSource,
    videoSourceType: videoSourceType,
    autoPlay: autoPlay ?? this.autoPlay,
    initialPosition: initialPosition ?? this.initialPosition,
    initialVolume: initialVolume ?? this.initialVolume,
    initialPlaybackSpeed: initialPlaybackSpeed ?? this.initialPlaybackSpeed,
    availablePlaybackSpeed:
        availablePlaybackSpeed ?? this.availablePlaybackSpeed,
    autoMuteOnStart: autoMuteOnStart ?? this.autoMuteOnStart,
    preferredQualities: newPreferred,
    availableQualities: newAvailable,
    allowSeeking: allowSeeking ?? this.allowSeeking,
    timeoutDuration: timeoutDuration ?? this.timeoutDuration,
    enableYoutubeWebViewFallback:
        enableYoutubeWebViewFallback ?? this.enableYoutubeWebViewFallback,
    forceYoutubeWebViewOnly:
        forceYoutubeWebViewOnly ?? this.forceYoutubeWebViewOnly,
    synchronizeMuteAcrossPlayers:
        synchronizeMuteAcrossPlayers ?? this.synchronizeMuteAcrossPlayers,
  );
}