Skip to content

Commit

Permalink
Merge branch 'cristian1980-minor' into minor
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanheise committed Oct 29, 2024
2 parents 35a33da + 4322bf7 commit 7beeb16
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions just_audio/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.9.42

* Fix dealloc crash on iOS/macOS (@cristian1980).

## 0.9.41

* Fix stop() to cause play() to return on iOS.
Expand Down
6 changes: 4 additions & 2 deletions just_audio/darwin/Classes/AudioPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -1326,13 +1326,15 @@ - (void)seek:(CMTime)position index:(NSNumber *)newIndex completionHandler:(void
}
}

- (void)dispose {
- (void)dispose:(BOOL)calledFromDealloc {
if (!_player) return;
if (_processingState != none) {
[_player pause];

[self updatePosition];
[self broadcastPlaybackEvent];
if (!calledFromDealloc) {
[self broadcastPlaybackEvent];
}
if (_playResult) {
//NSLog(@"PLAY FINISHED DUE TO STOP");
_playResult(@{});
Expand Down
6 changes: 3 additions & 3 deletions just_audio/darwin/Classes/JustAudioPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
} else if ([@"disposePlayer" isEqualToString:call.method]) {
NSDictionary *request = (NSDictionary *)call.arguments;
NSString *playerId = request[@"id"];
[_players[playerId] dispose];
[_players[playerId] dispose:NO];
[_players setValue:nil forKey:playerId];
result(@{});
} else if ([@"disposeAllPlayers" isEqualToString:call.method]) {
for (NSString *playerId in _players) {
[_players[playerId] dispose];
[_players[playerId] dispose:NO];
}
[_players removeAllObjects];
result(@{});
Expand All @@ -56,7 +56,7 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {

- (void)dealloc {
for (NSString *playerId in _players) {
[_players[playerId] dispose];
[_players[playerId] dispose:YES];
}
[_players removeAllObjects];
}
Expand Down
2 changes: 1 addition & 1 deletion just_audio/ios/Classes/AudioPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@property (readonly, nonatomic) float speed;

- (instancetype)initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar playerId:(NSString*)idParam loadConfiguration:(NSDictionary *)loadConfiguration;
- (void)dispose;
- (void)dispose:(BOOL)calledFromDealloc;

@end

Expand Down
2 changes: 1 addition & 1 deletion just_audio/macos/Classes/AudioPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@property (readonly, nonatomic) float speed;

- (instancetype)initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar playerId:(NSString*)idParam loadConfiguration:(NSDictionary *)loadConfiguration;
- (void)dispose;
- (void)dispose:(BOOL)calledFromDealloc;

@end

Expand Down
2 changes: 1 addition & 1 deletion just_audio/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: just_audio
description: A feature-rich audio player for Flutter. Loop, clip and concatenate any sound from any source (asset/file/URL/stream) in a variety of audio formats with gapless playback.
version: 0.9.41
version: 0.9.42
repository: https://github.com/ryanheise/just_audio/tree/minor/just_audio
issue_tracker: https://github.com/ryanheise/just_audio/issues
topics:
Expand Down

0 comments on commit 7beeb16

Please sign in to comment.