Skip to content

feat: expose playback speed control to Flutter on iOS#7

Merged
Nisarg-18 merged 2 commits into
masterfrom
ns_playback_speed
Mar 3, 2026
Merged

feat: expose playback speed control to Flutter on iOS#7
Nisarg-18 merged 2 commits into
masterfrom
ns_playback_speed

Conversation

@Nisarg-18

Copy link
Copy Markdown
Collaborator

Wire up the existing native iOS setSpeed implementation to Flutter through the full method channel pipeline:

  • Add "setSpeed" case to iOS method channel handler in FLTBetterPlayerPlugin
  • Simplify iOS setSpeed() to remove overly restrictive capability checks
  • Add setSpeed() to VideoPlayerPlatform interface
  • Add setSpeed() to MethodChannelVideoPlayer
  • Add setSpeed() to VideoPlayerController
  • Add setSpeed() to BetterPlayerController with error handling

The Android side already had this wired up via BetterPlayerPlugin.java.

Speed range is 0.0 to 2.0, where 1.0 is normal playback.

@Nisarg-18 Nisarg-18 self-assigned this Feb 27, 2026
Comment thread example/ios/Flutter/ephemeral/flutter_lldb_helper.py
Comment thread example/ios/Flutter/ephemeral/flutter_lldbinit

@NicholasNagy NicholasNagy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also need to do something on the android side?

Comment thread ios/Classes/FLTBetterPlayerPlugin.swift Outdated
playerRate = 1.0
result(nil)
} else if speed < 0 || speed > 2.0 {
if speed < 0 || speed > 2.0 {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to check this here? Can't we check this in the dart code so that we don't need to duplicate this code in the android side as well?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good suggestion. I'll remove the check from here and add it dart layer to avoid duplication

await videoPlayerController!.setSpeed(speed);
return true;
} catch (_) {
return false;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like if we just return a boolean, users will have a tendency just to ignore it, as I wouldn't expect anyone to react any specific way if the setSpeed functionality doesn't work. I feel like an exception is more appropriate to throw (or rethrow in this case), so that users are aware there is an issue

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I agree, I'll update it

Comment thread example/ios/Flutter/ephemeral/flutter_lldb_helper.py
@Nisarg-18

Nisarg-18 commented Mar 1, 2026

Copy link
Copy Markdown
Collaborator Author

Do we also need to do something on the android side?

No, we do not need to make changes on android side. It is already implemented. BetterPlayerPlugin.java has the setSpeed case in its method channel handler, passing the "speed" parameter to the player. BetterPlayer.java implements setSpeed() which sets ExoPlayer's PlaybackParameters

Why do we have these auto generated files, and why are they being auto generated?

I'm not sure why these new files were generated but looks like these two files are automatically generated by flutter when you build the example iOS app (maybe because a change in flutter version)

@Nisarg-18 Nisarg-18 requested a review from NicholasNagy March 1, 2026 18:09
@Nisarg-18 Nisarg-18 merged commit dc08bbe into master Mar 3, 2026
0 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants