Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ @interface FLTVideoPlayer : NSObject <FlutterTexture, FlutterStreamHandler>
@property(nonatomic, readonly) bool disposed;
@property(nonatomic, readonly) bool isPlaying;
@property(nonatomic) bool isLooping;
@property(nonatomic) double internalPlaybackSpeed;
@property(nonatomic, readonly) bool isInitialized;
- (instancetype)initWithURL:(NSURL*)url
frameUpdater:(FLTFrameUpdater*)frameUpdater
Expand Down Expand Up @@ -310,6 +311,9 @@ - (void)updatePlayingState {
}
if (_isPlaying) {
[_player play];

// fix to always set playback speed accurately
[self setPlaybackSpeed:_internalPlaybackSpeed];
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this always needed here? My impression from comments in the issue was that calling it from the completion handler of the seek method would likely be enough.

Copy link
Author

Choose a reason for hiding this comment

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

@stuartmorgan which completion handler are you referring to? I only see a seekTo method in the file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

@stuartmorgan I see. I tried moving the call inside the completionHandler block of the seekTo method as follows:

[_player seekToTime:CMTimeMake(location, 1000)
      toleranceBefore:kCMTimeZero
       toleranceAfter:kCMTimeZero
    completionHandler:^(BOOL finished) {
    [self setPlaybackSpeed:_internalPlaybackSpeed];
  }];

but the issue of the playback speed resetting to 1.0 came back. Therefore that is not equivalent.

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting. So presumably then it's the playbackLikelyToKeepUpContext and/or AVPlayerItemStatusReadyToPlay codepath that's resolving this? In which case perhaps the underlying issue is that AVPlayer automatically resets the playback speed when the buffer is insufficient.

} else {
[_player pause];
}
Expand Down Expand Up @@ -394,6 +398,7 @@ - (void)setPlaybackSpeed:(double)speed {
return;
}

[self setInternalPlaybackSpeed:speed];
_player.rate = speed;
}

Expand Down