// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v26.3.4), do not edit directly.
// See also: https://pub.dev/packages/pigeon
// ignore_for_file: unused_import, unused_shown_name
// ignore_for_file: type=lint

import 'dart:async';
import 'dart:typed_data' show Float64List, Int32List, Int64List;

import 'package:flutter/services.dart';
import 'package:meta/meta.dart' show immutable, protected, visibleForTesting;

Object? _extractReplyValueOrThrow(
  List<Object?>? replyList,
  String channelName, {
  required bool isNullValid,
}) {
  if (replyList == null) {
    throw PlatformException(
      code: 'channel-error',
      message: 'Unable to establish connection on channel: "$channelName".',
    );
  } else if (replyList.length > 1) {
    throw PlatformException(
      code: replyList[0]! as String,
      message: replyList[1] as String?,
      details: replyList[2],
    );
  } else if (!isNullValid && (replyList.isNotEmpty && replyList[0] == null)) {
    throw PlatformException(
      code: 'null-error',
      message: 'Host platform returned null value for non-null return value.',
    );
  }
  return replyList.firstOrNull;
}

bool _deepEquals(Object? a, Object? b) {
  if (identical(a, b)) {
    return true;
  }
  if (a is double && b is double) {
    if (a.isNaN && b.isNaN) {
      return true;
    }
    return a == b;
  }
  if (a is List && b is List) {
    return a.length == b.length &&
        a.indexed.every(((int, dynamic) item) => _deepEquals(item.$2, b[item.$1]));
  }
  if (a is Map && b is Map) {
    if (a.length != b.length) {
      return false;
    }
    for (final MapEntry<Object?, Object?> entryA in a.entries) {
      bool found = false;
      for (final MapEntry<Object?, Object?> entryB in b.entries) {
        if (_deepEquals(entryA.key, entryB.key)) {
          if (_deepEquals(entryA.value, entryB.value)) {
            found = true;
            break;
          } else {
            return false;
          }
        }
      }
      if (!found) {
        return false;
      }
    }
    return true;
  }
  return a == b;
}

int _deepHash(Object? value) {
  if (value is List) {
    return Object.hashAll(value.map(_deepHash));
  }
  if (value is Map) {
    int result = 0;
    for (final MapEntry<Object?, Object?> entry in value.entries) {
      result += (_deepHash(entry.key) * 31) ^ _deepHash(entry.value);
    }
    return result;
  }
  if (value is double && value.isNaN) {
    // Normalize NaN to a consistent hash.
    return 0x7FF8000000000000.hashCode;
  }
  if (value is double && value == 0.0) {
    // Normalize -0.0 to 0.0 so they have the same hash code.
    return 0.0.hashCode;
  }
  return value.hashCode;
}

/// Pigeon equivalent of video_platform_interface's VideoFormat.
enum PlatformVideoFormat { dash, hls, ss }

/// Pigeon equivalent of Player's playback state.
/// https://developer.android.com/media/media3/exoplayer/listening-to-player-events#playback-state
enum PlatformPlaybackState { idle, buffering, ready, ended, unknown }

sealed class PlatformVideoEvent {}

/// Sent when the video is initialized and ready to play.
class InitializationEvent extends PlatformVideoEvent {
  InitializationEvent({
    required this.duration,
    required this.width,
    required this.height,
    required this.rotationCorrection,
  });

  /// The video duration in milliseconds.
  int duration;

  /// The width of the video in pixels.
  int width;

  /// The height of the video in pixels.
  int height;

  /// The rotation that should be applied during playback.
  int rotationCorrection;

  List<Object?> _toList() {
    return <Object?>[duration, width, height, rotationCorrection];
  }

  Object encode() {
    return _toList();
  }

  static InitializationEvent decode(Object result) {
    result as List<Object?>;
    return InitializationEvent(
      duration: result[0]! as int,
      width: result[1]! as int,
      height: result[2]! as int,
      rotationCorrection: result[3]! as int,
    );
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  bool operator ==(Object other) {
    if (other is! InitializationEvent || other.runtimeType != runtimeType) {
      return false;
    }
    if (identical(this, other)) {
      return true;
    }
    return _deepEquals(duration, other.duration) &&
        _deepEquals(width, other.width) &&
        _deepEquals(height, other.height) &&
        _deepEquals(rotationCorrection, other.rotationCorrection);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
}

/// Sent when the video state changes.
///
/// Corresponds to ExoPlayer's onPlaybackStateChanged.
class PlaybackStateChangeEvent extends PlatformVideoEvent {
  PlaybackStateChangeEvent({required this.state});

  PlatformPlaybackState state;

  List<Object?> _toList() {
    return <Object?>[state];
  }

  Object encode() {
    return _toList();
  }

  static PlaybackStateChangeEvent decode(Object result) {
    result as List<Object?>;
    return PlaybackStateChangeEvent(state: result[0]! as PlatformPlaybackState);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  bool operator ==(Object other) {
    if (other is! PlaybackStateChangeEvent || other.runtimeType != runtimeType) {
      return false;
    }
    if (identical(this, other)) {
      return true;
    }
    return _deepEquals(state, other.state);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
}

/// Sent when the video starts or stops playing.
///
/// Corresponds to ExoPlayer's onIsPlayingChanged.
class IsPlayingStateEvent extends PlatformVideoEvent {
  IsPlayingStateEvent({required this.isPlaying});

  bool isPlaying;

  List<Object?> _toList() {
    return <Object?>[isPlaying];
  }

  Object encode() {
    return _toList();
  }

  static IsPlayingStateEvent decode(Object result) {
    result as List<Object?>;
    return IsPlayingStateEvent(isPlaying: result[0]! as bool);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  bool operator ==(Object other) {
    if (other is! IsPlayingStateEvent || other.runtimeType != runtimeType) {
      return false;
    }
    if (identical(this, other)) {
      return true;
    }
    return _deepEquals(isPlaying, other.isPlaying);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
}

/// Sent when audio tracks change.
///
/// This includes when the selected audio track changes after calling selectAudioTrack.
/// Corresponds to ExoPlayer's onTracksChanged.
class AudioTrackChangedEvent extends PlatformVideoEvent {
  AudioTrackChangedEvent({this.selectedTrackId});

  /// The ID of the newly selected audio track, if any.
  String? selectedTrackId;

  List<Object?> _toList() {
    return <Object?>[selectedTrackId];
  }

  Object encode() {
    return _toList();
  }

  static AudioTrackChangedEvent decode(Object result) {
    result as List<Object?>;
    return AudioTrackChangedEvent(selectedTrackId: result[0] as String?);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  bool operator ==(Object other) {
    if (other is! AudioTrackChangedEvent || other.runtimeType != runtimeType) {
      return false;
    }
    if (identical(this, other)) {
      return true;
    }
    return _deepEquals(selectedTrackId, other.selectedTrackId);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
}

/// Sent when video tracks change.
///
/// This includes when the selected video track changes after calling selectVideoTrack.
/// Corresponds to ExoPlayer's onTracksChanged.
class VideoTrackChangedEvent extends PlatformVideoEvent {
  VideoTrackChangedEvent({this.selectedTrackId});

  /// The ID of the newly selected video track, if any.
  /// Will be null when auto quality selection is enabled.
  String? selectedTrackId;

  List<Object?> _toList() {
    return <Object?>[selectedTrackId];
  }

  Object encode() {
    return _toList();
  }

  static VideoTrackChangedEvent decode(Object result) {
    result as List<Object?>;
    return VideoTrackChangedEvent(selectedTrackId: result[0] as String?);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  bool operator ==(Object other) {
    if (other is! VideoTrackChangedEvent || other.runtimeType != runtimeType) {
      return false;
    }
    if (identical(this, other)) {
      return true;
    }
    return _deepEquals(selectedTrackId, other.selectedTrackId);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
}

/// Information passed to the platform view creation.
class PlatformVideoViewCreationParams {
  PlatformVideoViewCreationParams({required this.playerId});

  int playerId;

  List<Object?> _toList() {
    return <Object?>[playerId];
  }

  Object encode() {
    return _toList();
  }

  static PlatformVideoViewCreationParams decode(Object result) {
    result as List<Object?>;
    return PlatformVideoViewCreationParams(playerId: result[0]! as int);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  bool operator ==(Object other) {
    if (other is! PlatformVideoViewCreationParams || other.runtimeType != runtimeType) {
      return false;
    }
    if (identical(this, other)) {
      return true;
    }
    return _deepEquals(playerId, other.playerId);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
}

class CreationOptions {
  CreationOptions({
    required this.uri,
    this.formatHint,
    required this.httpHeaders,
    this.userAgent,
    this.backBufferDurationMs,
  });

  String uri;

  PlatformVideoFormat? formatHint;

  Map<String, String> httpHeaders;

  String? userAgent;

  int? backBufferDurationMs;

  List<Object?> _toList() {
    return <Object?>[uri, formatHint, httpHeaders, userAgent, backBufferDurationMs];
  }

  Object encode() {
    return _toList();
  }

  static CreationOptions decode(Object result) {
    result as List<Object?>;
    return CreationOptions(
      uri: result[0]! as String,
      formatHint: result[1] as PlatformVideoFormat?,
      httpHeaders: (result[2]! as Map<Object?, Object?>).cast<String, String>(),
      userAgent: result[3] as String?,
      backBufferDurationMs: result[4] as int?,
    );
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  bool operator ==(Object other) {
    if (other is! CreationOptions || other.runtimeType != runtimeType) {
      return false;
    }
    if (identical(this, other)) {
      return true;
    }
    return _deepEquals(uri, other.uri) &&
        _deepEquals(formatHint, other.formatHint) &&
        _deepEquals(httpHeaders, other.httpHeaders) &&
        _deepEquals(userAgent, other.userAgent) &&
        _deepEquals(backBufferDurationMs, other.backBufferDurationMs);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
}

class TexturePlayerIds {
  TexturePlayerIds({required this.playerId, required this.textureId});

  int playerId;

  int textureId;

  List<Object?> _toList() {
    return <Object?>[playerId, textureId];
  }

  Object encode() {
    return _toList();
  }

  static TexturePlayerIds decode(Object result) {
    result as List<Object?>;
    return TexturePlayerIds(playerId: result[0]! as int, textureId: result[1]! as int);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  bool operator ==(Object other) {
    if (other is! TexturePlayerIds || other.runtimeType != runtimeType) {
      return false;
    }
    if (identical(this, other)) {
      return true;
    }
    return _deepEquals(playerId, other.playerId) && _deepEquals(textureId, other.textureId);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
}

class PlaybackState {
  PlaybackState({required this.playPosition, required this.bufferPosition});

  /// The current playback position, in milliseconds.
  int playPosition;

  /// The current buffer position, in milliseconds.
  int bufferPosition;

  List<Object?> _toList() {
    return <Object?>[playPosition, bufferPosition];
  }

  Object encode() {
    return _toList();
  }

  static PlaybackState decode(Object result) {
    result as List<Object?>;
    return PlaybackState(playPosition: result[0]! as int, bufferPosition: result[1]! as int);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  bool operator ==(Object other) {
    if (other is! PlaybackState || other.runtimeType != runtimeType) {
      return false;
    }
    if (identical(this, other)) {
      return true;
    }
    return _deepEquals(playPosition, other.playPosition) &&
        _deepEquals(bufferPosition, other.bufferPosition);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
}

/// Represents an audio track in a video.
class AudioTrackMessage {
  AudioTrackMessage({
    required this.id,
    required this.label,
    required this.language,
    required this.isSelected,
    this.bitrate,
    this.sampleRate,
    this.channelCount,
    this.codec,
  });

  String id;

  String label;

  String language;

  bool isSelected;

  int? bitrate;

  int? sampleRate;

  int? channelCount;

  String? codec;

  List<Object?> _toList() {
    return <Object?>[id, label, language, isSelected, bitrate, sampleRate, channelCount, codec];
  }

  Object encode() {
    return _toList();
  }

  static AudioTrackMessage decode(Object result) {
    result as List<Object?>;
    return AudioTrackMessage(
      id: result[0]! as String,
      label: result[1]! as String,
      language: result[2]! as String,
      isSelected: result[3]! as bool,
      bitrate: result[4] as int?,
      sampleRate: result[5] as int?,
      channelCount: result[6] as int?,
      codec: result[7] as String?,
    );
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  bool operator ==(Object other) {
    if (other is! AudioTrackMessage || other.runtimeType != runtimeType) {
      return false;
    }
    if (identical(this, other)) {
      return true;
    }
    return _deepEquals(id, other.id) &&
        _deepEquals(label, other.label) &&
        _deepEquals(language, other.language) &&
        _deepEquals(isSelected, other.isSelected) &&
        _deepEquals(bitrate, other.bitrate) &&
        _deepEquals(sampleRate, other.sampleRate) &&
        _deepEquals(channelCount, other.channelCount) &&
        _deepEquals(codec, other.codec);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
}

/// Raw audio track data from ExoPlayer Format objects.
class ExoPlayerAudioTrackData {
  ExoPlayerAudioTrackData({
    required this.groupIndex,
    required this.trackIndex,
    this.label,
    this.language,
    required this.isSelected,
    this.bitrate,
    this.sampleRate,
    this.channelCount,
    this.codec,
  });

  int groupIndex;

  int trackIndex;

  String? label;

  String? language;

  bool isSelected;

  int? bitrate;

  int? sampleRate;

  int? channelCount;

  String? codec;

  List<Object?> _toList() {
    return <Object?>[
      groupIndex,
      trackIndex,
      label,
      language,
      isSelected,
      bitrate,
      sampleRate,
      channelCount,
      codec,
    ];
  }

  Object encode() {
    return _toList();
  }

  static ExoPlayerAudioTrackData decode(Object result) {
    result as List<Object?>;
    return ExoPlayerAudioTrackData(
      groupIndex: result[0]! as int,
      trackIndex: result[1]! as int,
      label: result[2] as String?,
      language: result[3] as String?,
      isSelected: result[4]! as bool,
      bitrate: result[5] as int?,
      sampleRate: result[6] as int?,
      channelCount: result[7] as int?,
      codec: result[8] as String?,
    );
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  bool operator ==(Object other) {
    if (other is! ExoPlayerAudioTrackData || other.runtimeType != runtimeType) {
      return false;
    }
    if (identical(this, other)) {
      return true;
    }
    return _deepEquals(groupIndex, other.groupIndex) &&
        _deepEquals(trackIndex, other.trackIndex) &&
        _deepEquals(label, other.label) &&
        _deepEquals(language, other.language) &&
        _deepEquals(isSelected, other.isSelected) &&
        _deepEquals(bitrate, other.bitrate) &&
        _deepEquals(sampleRate, other.sampleRate) &&
        _deepEquals(channelCount, other.channelCount) &&
        _deepEquals(codec, other.codec);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
}

/// Container for raw audio track data from Android ExoPlayer.
class NativeAudioTrackData {
  NativeAudioTrackData({this.exoPlayerTracks});

  /// ExoPlayer-based tracks
  List<ExoPlayerAudioTrackData>? exoPlayerTracks;

  List<Object?> _toList() {
    return <Object?>[exoPlayerTracks];
  }

  Object encode() {
    return _toList();
  }

  static NativeAudioTrackData decode(Object result) {
    result as List<Object?>;
    return NativeAudioTrackData(
      exoPlayerTracks: (result[0] as List<Object?>?)?.cast<ExoPlayerAudioTrackData>(),
    );
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  bool operator ==(Object other) {
    if (other is! NativeAudioTrackData || other.runtimeType != runtimeType) {
      return false;
    }
    if (identical(this, other)) {
      return true;
    }
    return _deepEquals(exoPlayerTracks, other.exoPlayerTracks);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
}

/// Raw video track data from ExoPlayer Format objects.
class ExoPlayerVideoTrackData {
  ExoPlayerVideoTrackData({
    required this.groupIndex,
    required this.trackIndex,
    this.label,
    required this.isSelected,
    this.bitrate,
    this.width,
    this.height,
    this.frameRate,
    this.codec,
  });

  int groupIndex;

  int trackIndex;

  String? label;

  bool isSelected;

  int? bitrate;

  int? width;

  int? height;

  double? frameRate;

  String? codec;

  List<Object?> _toList() {
    return <Object?>[
      groupIndex,
      trackIndex,
      label,
      isSelected,
      bitrate,
      width,
      height,
      frameRate,
      codec,
    ];
  }

  Object encode() {
    return _toList();
  }

  static ExoPlayerVideoTrackData decode(Object result) {
    result as List<Object?>;
    return ExoPlayerVideoTrackData(
      groupIndex: result[0]! as int,
      trackIndex: result[1]! as int,
      label: result[2] as String?,
      isSelected: result[3]! as bool,
      bitrate: result[4] as int?,
      width: result[5] as int?,
      height: result[6] as int?,
      frameRate: result[7] as double?,
      codec: result[8] as String?,
    );
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  bool operator ==(Object other) {
    if (other is! ExoPlayerVideoTrackData || other.runtimeType != runtimeType) {
      return false;
    }
    if (identical(this, other)) {
      return true;
    }
    return _deepEquals(groupIndex, other.groupIndex) &&
        _deepEquals(trackIndex, other.trackIndex) &&
        _deepEquals(label, other.label) &&
        _deepEquals(isSelected, other.isSelected) &&
        _deepEquals(bitrate, other.bitrate) &&
        _deepEquals(width, other.width) &&
        _deepEquals(height, other.height) &&
        _deepEquals(frameRate, other.frameRate) &&
        _deepEquals(codec, other.codec);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
}

/// Container for raw video track data from Android ExoPlayer.
class NativeVideoTrackData {
  NativeVideoTrackData({this.exoPlayerTracks});

  /// ExoPlayer-based tracks
  List<ExoPlayerVideoTrackData>? exoPlayerTracks;

  List<Object?> _toList() {
    return <Object?>[exoPlayerTracks];
  }

  Object encode() {
    return _toList();
  }

  static NativeVideoTrackData decode(Object result) {
    result as List<Object?>;
    return NativeVideoTrackData(
      exoPlayerTracks: (result[0] as List<Object?>?)?.cast<ExoPlayerVideoTrackData>(),
    );
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  bool operator ==(Object other) {
    if (other is! NativeVideoTrackData || other.runtimeType != runtimeType) {
      return false;
    }
    if (identical(this, other)) {
      return true;
    }
    return _deepEquals(exoPlayerTracks, other.exoPlayerTracks);
  }

  @override
  // ignore: avoid_equals_and_hash_code_on_mutable_classes
  int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
}

class _PigeonCodec extends StandardMessageCodec {
  const _PigeonCodec();
  @override
  void writeValue(WriteBuffer buffer, Object? value) {
    if (value is int) {
      buffer.putUint8(4);
      buffer.putInt64(value);
    } else if (value is PlatformVideoFormat) {
      buffer.putUint8(129);
      writeValue(buffer, value.index);
    } else if (value is PlatformPlaybackState) {
      buffer.putUint8(130);
      writeValue(buffer, value.index);
    } else if (value is InitializationEvent) {
      buffer.putUint8(131);
      writeValue(buffer, value.encode());
    } else if (value is PlaybackStateChangeEvent) {
      buffer.putUint8(132);
      writeValue(buffer, value.encode());
    } else if (value is IsPlayingStateEvent) {
      buffer.putUint8(133);
      writeValue(buffer, value.encode());
    } else if (value is AudioTrackChangedEvent) {
      buffer.putUint8(134);
      writeValue(buffer, value.encode());
    } else if (value is VideoTrackChangedEvent) {
      buffer.putUint8(135);
      writeValue(buffer, value.encode());
    } else if (value is PlatformVideoViewCreationParams) {
      buffer.putUint8(136);
      writeValue(buffer, value.encode());
    } else if (value is CreationOptions) {
      buffer.putUint8(137);
      writeValue(buffer, value.encode());
    } else if (value is TexturePlayerIds) {
      buffer.putUint8(138);
      writeValue(buffer, value.encode());
    } else if (value is PlaybackState) {
      buffer.putUint8(139);
      writeValue(buffer, value.encode());
    } else if (value is AudioTrackMessage) {
      buffer.putUint8(140);
      writeValue(buffer, value.encode());
    } else if (value is ExoPlayerAudioTrackData) {
      buffer.putUint8(141);
      writeValue(buffer, value.encode());
    } else if (value is NativeAudioTrackData) {
      buffer.putUint8(142);
      writeValue(buffer, value.encode());
    } else if (value is ExoPlayerVideoTrackData) {
      buffer.putUint8(143);
      writeValue(buffer, value.encode());
    } else if (value is NativeVideoTrackData) {
      buffer.putUint8(144);
      writeValue(buffer, value.encode());
    } else {
      super.writeValue(buffer, value);
    }
  }

  @override
  Object? readValueOfType(int type, ReadBuffer buffer) {
    switch (type) {
      case 129:
        final value = readValue(buffer) as int?;
        return value == null ? null : PlatformVideoFormat.values[value];
      case 130:
        final value = readValue(buffer) as int?;
        return value == null ? null : PlatformPlaybackState.values[value];
      case 131:
        return InitializationEvent.decode(readValue(buffer)!);
      case 132:
        return PlaybackStateChangeEvent.decode(readValue(buffer)!);
      case 133:
        return IsPlayingStateEvent.decode(readValue(buffer)!);
      case 134:
        return AudioTrackChangedEvent.decode(readValue(buffer)!);
      case 135:
        return VideoTrackChangedEvent.decode(readValue(buffer)!);
      case 136:
        return PlatformVideoViewCreationParams.decode(readValue(buffer)!);
      case 137:
        return CreationOptions.decode(readValue(buffer)!);
      case 138:
        return TexturePlayerIds.decode(readValue(buffer)!);
      case 139:
        return PlaybackState.decode(readValue(buffer)!);
      case 140:
        return AudioTrackMessage.decode(readValue(buffer)!);
      case 141:
        return ExoPlayerAudioTrackData.decode(readValue(buffer)!);
      case 142:
        return NativeAudioTrackData.decode(readValue(buffer)!);
      case 143:
        return ExoPlayerVideoTrackData.decode(readValue(buffer)!);
      case 144:
        return NativeVideoTrackData.decode(readValue(buffer)!);
      default:
        return super.readValueOfType(type, buffer);
    }
  }
}

const StandardMethodCodec pigeonMethodCodec = StandardMethodCodec(_PigeonCodec());

class AndroidVideoPlayerApi {
  /// Constructor for [AndroidVideoPlayerApi].  The [binaryMessenger] named argument is
  /// available for dependency injection.  If it is left null, the default
  /// BinaryMessenger will be used which routes to the host platform.
  AndroidVideoPlayerApi({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''})
    : pigeonVar_binaryMessenger = binaryMessenger,
      pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty
          ? '.$messageChannelSuffix'
          : '';
  final BinaryMessenger? pigeonVar_binaryMessenger;

  static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();

  final String pigeonVar_messageChannelSuffix;

  Future<void> initialize() async {
    final pigeonVar_channelName =
        'dev.flutter.pigeon.video_player_android.AndroidVideoPlayerApi.initialize$pigeonVar_messageChannelSuffix';
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      pigeonVar_channelName,
      pigeonChannelCodec,
      binaryMessenger: pigeonVar_binaryMessenger,
    );
    final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
    final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;

    _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true);
  }

  Future<int> createForPlatformView(CreationOptions options) async {
    final pigeonVar_channelName =
        'dev.flutter.pigeon.video_player_android.AndroidVideoPlayerApi.createForPlatformView$pigeonVar_messageChannelSuffix';
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      pigeonVar_channelName,
      pigeonChannelCodec,
      binaryMessenger: pigeonVar_binaryMessenger,
    );
    final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[options]);
    final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;

    final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
      pigeonVar_replyList,
      pigeonVar_channelName,
      isNullValid: false,
    );
    return pigeonVar_replyValue! as int;
  }

  Future<TexturePlayerIds> createForTextureView(CreationOptions options) async {
    final pigeonVar_channelName =
        'dev.flutter.pigeon.video_player_android.AndroidVideoPlayerApi.createForTextureView$pigeonVar_messageChannelSuffix';
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      pigeonVar_channelName,
      pigeonChannelCodec,
      binaryMessenger: pigeonVar_binaryMessenger,
    );
    final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[options]);
    final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;

    final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
      pigeonVar_replyList,
      pigeonVar_channelName,
      isNullValid: false,
    );
    return pigeonVar_replyValue! as TexturePlayerIds;
  }

  Future<void> dispose(int playerId) async {
    final pigeonVar_channelName =
        'dev.flutter.pigeon.video_player_android.AndroidVideoPlayerApi.dispose$pigeonVar_messageChannelSuffix';
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      pigeonVar_channelName,
      pigeonChannelCodec,
      binaryMessenger: pigeonVar_binaryMessenger,
    );
    final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[playerId]);
    final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;

    _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true);
  }

  Future<void> setMixWithOthers(bool mixWithOthers) async {
    final pigeonVar_channelName =
        'dev.flutter.pigeon.video_player_android.AndroidVideoPlayerApi.setMixWithOthers$pigeonVar_messageChannelSuffix';
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      pigeonVar_channelName,
      pigeonChannelCodec,
      binaryMessenger: pigeonVar_binaryMessenger,
    );
    final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[mixWithOthers]);
    final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;

    _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true);
  }

  Future<String> getLookupKeyForAsset(String asset, String? packageName) async {
    final pigeonVar_channelName =
        'dev.flutter.pigeon.video_player_android.AndroidVideoPlayerApi.getLookupKeyForAsset$pigeonVar_messageChannelSuffix';
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      pigeonVar_channelName,
      pigeonChannelCodec,
      binaryMessenger: pigeonVar_binaryMessenger,
    );
    final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[
      asset,
      packageName,
    ]);
    final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;

    final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
      pigeonVar_replyList,
      pigeonVar_channelName,
      isNullValid: false,
    );
    return pigeonVar_replyValue! as String;
  }
}

class VideoPlayerInstanceApi {
  /// Constructor for [VideoPlayerInstanceApi].  The [binaryMessenger] named argument is
  /// available for dependency injection.  If it is left null, the default
  /// BinaryMessenger will be used which routes to the host platform.
  VideoPlayerInstanceApi({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''})
    : pigeonVar_binaryMessenger = binaryMessenger,
      pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty
          ? '.$messageChannelSuffix'
          : '';
  final BinaryMessenger? pigeonVar_binaryMessenger;

  static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();

  final String pigeonVar_messageChannelSuffix;

  /// Sets whether to automatically loop playback of the video.
  Future<void> setLooping(bool looping) async {
    final pigeonVar_channelName =
        'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.setLooping$pigeonVar_messageChannelSuffix';
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      pigeonVar_channelName,
      pigeonChannelCodec,
      binaryMessenger: pigeonVar_binaryMessenger,
    );
    final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[looping]);
    final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;

    _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true);
  }

  /// Sets the volume, with 0.0 being muted and 1.0 being full volume.
  Future<void> setVolume(double volume) async {
    final pigeonVar_channelName =
        'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.setVolume$pigeonVar_messageChannelSuffix';
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      pigeonVar_channelName,
      pigeonChannelCodec,
      binaryMessenger: pigeonVar_binaryMessenger,
    );
    final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[volume]);
    final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;

    _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true);
  }

  /// Sets the playback speed as a multiple of normal speed.
  Future<void> setPlaybackSpeed(double speed) async {
    final pigeonVar_channelName =
        'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.setPlaybackSpeed$pigeonVar_messageChannelSuffix';
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      pigeonVar_channelName,
      pigeonChannelCodec,
      binaryMessenger: pigeonVar_binaryMessenger,
    );
    final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[speed]);
    final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;

    _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true);
  }

  /// Begins playback if the video is not currently playing.
  Future<void> play() async {
    final pigeonVar_channelName =
        'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.play$pigeonVar_messageChannelSuffix';
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      pigeonVar_channelName,
      pigeonChannelCodec,
      binaryMessenger: pigeonVar_binaryMessenger,
    );
    final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
    final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;

    _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true);
  }

  /// Pauses playback if the video is currently playing.
  Future<void> pause() async {
    final pigeonVar_channelName =
        'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.pause$pigeonVar_messageChannelSuffix';
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      pigeonVar_channelName,
      pigeonChannelCodec,
      binaryMessenger: pigeonVar_binaryMessenger,
    );
    final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
    final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;

    _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true);
  }

  /// Seeks to the given playback position, in milliseconds.
  Future<void> seekTo(int position) async {
    final pigeonVar_channelName =
        'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.seekTo$pigeonVar_messageChannelSuffix';
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      pigeonVar_channelName,
      pigeonChannelCodec,
      binaryMessenger: pigeonVar_binaryMessenger,
    );
    final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[position]);
    final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;

    _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true);
  }

  /// Returns the current playback position, in milliseconds.
  Future<int> getCurrentPosition() async {
    final pigeonVar_channelName =
        'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.getCurrentPosition$pigeonVar_messageChannelSuffix';
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      pigeonVar_channelName,
      pigeonChannelCodec,
      binaryMessenger: pigeonVar_binaryMessenger,
    );
    final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
    final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;

    final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
      pigeonVar_replyList,
      pigeonVar_channelName,
      isNullValid: false,
    );
    return pigeonVar_replyValue! as int;
  }

  /// Returns the current buffer position, in milliseconds.
  Future<int> getBufferedPosition() async {
    final pigeonVar_channelName =
        'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.getBufferedPosition$pigeonVar_messageChannelSuffix';
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      pigeonVar_channelName,
      pigeonChannelCodec,
      binaryMessenger: pigeonVar_binaryMessenger,
    );
    final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
    final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;

    final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
      pigeonVar_replyList,
      pigeonVar_channelName,
      isNullValid: false,
    );
    return pigeonVar_replyValue! as int;
  }

  /// Gets the available audio tracks for the video.
  Future<NativeAudioTrackData> getAudioTracks() async {
    final pigeonVar_channelName =
        'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.getAudioTracks$pigeonVar_messageChannelSuffix';
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      pigeonVar_channelName,
      pigeonChannelCodec,
      binaryMessenger: pigeonVar_binaryMessenger,
    );
    final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
    final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;

    final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
      pigeonVar_replyList,
      pigeonVar_channelName,
      isNullValid: false,
    );
    return pigeonVar_replyValue! as NativeAudioTrackData;
  }

  /// Selects which audio track is chosen for playback from its [groupIndex] and [trackIndex]
  Future<void> selectAudioTrack(int groupIndex, int trackIndex) async {
    final pigeonVar_channelName =
        'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.selectAudioTrack$pigeonVar_messageChannelSuffix';
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      pigeonVar_channelName,
      pigeonChannelCodec,
      binaryMessenger: pigeonVar_binaryMessenger,
    );
    final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[
      groupIndex,
      trackIndex,
    ]);
    final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;

    _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true);
  }

  /// Gets the available video tracks for the video.
  Future<NativeVideoTrackData> getVideoTracks() async {
    final pigeonVar_channelName =
        'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.getVideoTracks$pigeonVar_messageChannelSuffix';
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      pigeonVar_channelName,
      pigeonChannelCodec,
      binaryMessenger: pigeonVar_binaryMessenger,
    );
    final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
    final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;

    final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
      pigeonVar_replyList,
      pigeonVar_channelName,
      isNullValid: false,
    );
    return pigeonVar_replyValue! as NativeVideoTrackData;
  }

  /// Selects which video track is chosen for playback from its [groupIndex] and [trackIndex].
  Future<void> selectVideoTrack(int groupIndex, int trackIndex) async {
    final pigeonVar_channelName =
        'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.selectVideoTrack$pigeonVar_messageChannelSuffix';
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      pigeonVar_channelName,
      pigeonChannelCodec,
      binaryMessenger: pigeonVar_binaryMessenger,
    );
    final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[
      groupIndex,
      trackIndex,
    ]);
    final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;

    _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true);
  }

  /// Enables automatic video quality selection, allowing the player to adaptively
  /// switch between available video tracks based on network conditions.
  Future<void> enableAutoVideoQuality() async {
    final pigeonVar_channelName =
        'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.enableAutoVideoQuality$pigeonVar_messageChannelSuffix';
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      pigeonVar_channelName,
      pigeonChannelCodec,
      binaryMessenger: pigeonVar_binaryMessenger,
    );
    final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
    final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;

    _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true);
  }
}

Stream<PlatformVideoEvent> videoEvents({String instanceName = ''}) {
  if (instanceName.isNotEmpty) {
    instanceName = '.$instanceName';
  }
  final EventChannel videoEventsChannel = EventChannel(
    'dev.flutter.pigeon.video_player_android.VideoEventChannel.videoEvents$instanceName',
    pigeonMethodCodec,
  );
  return videoEventsChannel.receiveBroadcastStream().map((dynamic event) {
    return event as PlatformVideoEvent;
  });
}
