Skip to content
Prev Previous commit
Review feedback
  • Loading branch information
stuartmorgan-g committed Aug 15, 2025
commit c328f2597a269e7086550d7e77292f949e19e58b
Original file line number Diff line number Diff line change
Expand Up @@ -631,18 +631,18 @@ static void setUp(
}
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
public interface VideoPlayerInstanceApi {

/** Sets whether to automatically loop playback of the video. */
void setLooping(@NonNull Boolean looping);

/** Sets the volume, with 0.0 being muted and 1.0 being full volume. */
void setVolume(@NonNull Double volume);

/** Sets the playback speed as a multiple of normal speed. */
void setPlaybackSpeed(@NonNull Double speed);

/** Begins playback if the video is not currently playing. */
void play();

void seekTo(@NonNull Long position);

/** Pauses playback if the video is currently playing. */
void pause();
/** Seeks to the given playback position, in milliseconds. */
void seekTo(@NonNull Long position);
/**
* Returns the current playback state.
*
Expand Down Expand Up @@ -772,17 +772,15 @@ static void setUp(
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.seekTo"
"dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.pause"
+ messageChannelSuffix,
getCodec());
if (api != null) {
channel.setMessageHandler(
(message, reply) -> {
ArrayList<Object> wrapped = new ArrayList<>();
ArrayList<Object> args = (ArrayList<Object>) message;
Long positionArg = (Long) args.get(0);
try {
api.seekTo(positionArg);
api.pause();
wrapped.add(0, null);
} catch (Throwable exception) {
wrapped = wrapError(exception);
Expand All @@ -797,15 +795,17 @@ static void setUp(
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.pause"
"dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.seekTo"
+ messageChannelSuffix,
getCodec());
if (api != null) {
channel.setMessageHandler(
(message, reply) -> {
ArrayList<Object> wrapped = new ArrayList<>();
ArrayList<Object> args = (ArrayList<Object>) message;
Long positionArg = (Long) args.get(0);
try {
api.pause();
api.seekTo(positionArg);
wrapped.add(0, null);
} catch (Throwable exception) {
wrapped = wrapError(exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import 'package:video_player_platform_interface/video_player_platform_interface.
import 'messages.g.dart';
import 'platform_view_player.dart';

/// The string to append a player ID to in order to construct the event channel
/// name for the event channel used to receive player state updates.
///
/// Must match the string used to create the EventChannel on the Java side.
const String _videoEventChannelNameBase = 'flutter.io/videoPlayer/videoEvents';

/// The non-test implementation of `_apiProvider`.
VideoPlayerInstanceApi _productionApiProvider(int playerId) {
return VideoPlayerInstanceApi(messageChannelSuffix: playerId.toString());
Expand Down Expand Up @@ -133,8 +139,7 @@ class AndroidVideoPlayer extends VideoPlayerPlatform {
),
VideoViewType.platformView => const _VideoPlayerPlatformViewState(),
};
final String eventChannelName =
'flutter.io/videoPlayer/videoEvents$playerId';
final String eventChannelName = '$_videoEventChannelNameBase$playerId';
return _PlayerInstance(
_playerProvider(playerId),
viewState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ class VideoPlayerInstanceApi {

final String pigeonVar_messageChannelSuffix;

/// Sets whether to automatically loop playback of the video.
Future<void> setLooping(bool looping) async {
final String pigeonVar_channelName =
'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.setLooping$pigeonVar_messageChannelSuffix';
Expand Down Expand Up @@ -428,6 +429,7 @@ class VideoPlayerInstanceApi {
}
}

/// Sets the volume, with 0.0 being muted and 1.0 being full volume.
Future<void> setVolume(double volume) async {
final String pigeonVar_channelName =
'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.setVolume$pigeonVar_messageChannelSuffix';
Expand Down Expand Up @@ -455,6 +457,7 @@ class VideoPlayerInstanceApi {
}
}

/// Sets the playback speed as a multiple of normal speed.
Future<void> setPlaybackSpeed(double speed) async {
final String pigeonVar_channelName =
'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.setPlaybackSpeed$pigeonVar_messageChannelSuffix';
Expand Down Expand Up @@ -482,6 +485,7 @@ class VideoPlayerInstanceApi {
}
}

/// Begins playback if the video is not currently playing.
Future<void> play() async {
final String pigeonVar_channelName =
'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.play$pigeonVar_messageChannelSuffix';
Expand All @@ -507,18 +511,17 @@ class VideoPlayerInstanceApi {
}
}

Future<void> seekTo(int position) async {
/// Pauses playback if the video is currently playing.
Future<void> pause() async {
final String pigeonVar_channelName =
'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.seekTo$pigeonVar_messageChannelSuffix';
'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.pause$pigeonVar_messageChannelSuffix';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
);
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
<Object?>[position],
);
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
final List<Object?>? pigeonVar_replyList =
await pigeonVar_sendFuture as List<Object?>?;
if (pigeonVar_replyList == null) {
Expand All @@ -534,16 +537,19 @@ class VideoPlayerInstanceApi {
}
}

Future<void> pause() async {
/// Seeks to the given playback position, in milliseconds.
Future<void> seekTo(int position) async {
final String pigeonVar_channelName =
'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.pause$pigeonVar_messageChannelSuffix';
'dev.flutter.pigeon.video_player_android.VideoPlayerInstanceApi.seekTo$pigeonVar_messageChannelSuffix';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
);
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
<Object?>[position],
);
final List<Object?>? pigeonVar_replyList =
await pigeonVar_sendFuture as List<Object?>?;
if (pigeonVar_replyList == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,24 @@ abstract class AndroidVideoPlayerApi {

@HostApi()
abstract class VideoPlayerInstanceApi {
/// Sets whether to automatically loop playback of the video.
void setLooping(bool looping);

/// Sets the volume, with 0.0 being muted and 1.0 being full volume.
void setVolume(double volume);

/// Sets the playback speed as a multiple of normal speed.
void setPlaybackSpeed(double speed);

/// Begins playback if the video is not currently playing.
void play();
void seekTo(int position);

/// Pauses playback if the video is currently playing.
void pause();

/// Seeks to the given playback position, in milliseconds.
void seekTo(int position);

/// Returns the current playback state.
///
/// This is combined into a single call to minimize platform channel calls for
Expand Down