Skip to content

Commit

Permalink
Voximplant Flutter SDK 2.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirBrejcha committed Nov 5, 2020
1 parent 5b24e0c commit abab4ff
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 2.4.3
* Fix a bug leading to non-execution of VIAudioFile.stop() Future in some cases

## 2.4.2
* Fix a crash on stop non-looped VIAudioFile (iOS)

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'com.voximplant.flutter_voximplant'
version '2.4.2'
version '2.4.3'

buildscript {
repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class AudioFileModule implements EventChannel.StreamHandler, IAudioFileLi
private MethodChannel.Result mLoadFileCompletion;
private MethodChannel.Result mPlayCompletion;
private MethodChannel.Result mStopCompletion;
private boolean mIsPlaying;

AudioFileModule(BinaryMessenger messenger, IAudioFile file, String fileId, MethodChannel.Result loadFileCompletion) {
mLoadFileCompletion = loadFileCompletion;
Expand All @@ -31,6 +32,7 @@ public class AudioFileModule implements EventChannel.StreamHandler, IAudioFileLi
mFileId = fileId;
mAudioFile = file;
mAudioFile.setAudioFileListener(this);
mIsPlaying = false;
}

void handleMethodCall(MethodCall call, MethodChannel.Result result) {
Expand Down Expand Up @@ -61,13 +63,18 @@ void play(MethodCall call, MethodChannel.Result result) {

void stop(MethodChannel.Result result) {
if (mAudioFile != null) {
mStopCompletion = result;
mAudioFile.stop(false);
if (mIsPlaying) {
mStopCompletion = result;
mAudioFile.stop(false);
} else {
result.success(null);
}
}
}

@Override
public void onStart(IAudioFile audioFile) {
mIsPlaying = true;
if (mPlayCompletion != null) {
mHandler.post(() -> {
mPlayCompletion.success(null);
Expand All @@ -78,6 +85,7 @@ public void onStart(IAudioFile audioFile) {

@Override
public void onStop(IAudioFile audioFile) {
mIsPlaying = false;
if (mStopCompletion != null) {
mHandler.post(() -> {
mStopCompletion.success(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class VoximplantPlugin implements MethodCallHandler, FlutterPlugin {
private AudioFileManager mAudioFileManager;

public VoximplantPlugin() {
Voximplant.subVersion = "flutter-2.4.2";
Voximplant.subVersion = "flutter-2.4.3";
}

private void configure(Context context, TextureRegistry textures, BinaryMessenger messenger) {
Expand Down
12 changes: 10 additions & 2 deletions ios/Classes/VIAudioFileModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ @interface VIAudioFileModule ()
@property(nonatomic, strong) NSString *fileID;
@property(nonatomic) FlutterResult playCompletion;
@property(nonatomic) FlutterResult stopCompletion;
@property(atomic) BOOL isPlaying;

@end

Expand All @@ -30,6 +31,7 @@ - (instancetype)initWithPlugin:(VoximplantPlugin *)plugin audioFile:(VIAudioFile
_fileID = fileID;
_audioFile = file;
_audioFile.delegate = self;
_isPlaying = NO;
}
return self;
}
Expand All @@ -51,8 +53,12 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
[_audioFile play];
_playCompletion = result;
} else if ([@"stop" isEqualToString:call.method]) {
[_audioFile stop];
_stopCompletion = result;
if (_isPlaying) {
[_audioFile stop];
_stopCompletion = result;
} else {
result(nil);
}
} else {
result(FlutterMethodNotImplemented);
}
Expand All @@ -66,13 +72,15 @@ - (void)audioFile:(VIAudioFile *)audioFile didStartPlaying:(NSError *)playbackEr
message:playbackError.localizedDescription
details:nil]);
} else {
_isPlaying = YES;
_playCompletion(nil);
}
_playCompletion = nil;
}
}

- (void)audioFile:(VIAudioFile *)audioFile didStopPlaying:(NSError *)playbackError {
_isPlaying = NO;
if (_stopCompletion) {
if (playbackError) {
_stopCompletion([FlutterError errorWithCode:[VoximplantUtils convertAudioFileErrorToString:playbackError.code]
Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/VoximplantPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ - (instancetype)initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar
self.audioFileManager = [[VIAudioFileManager alloc] initWithPlugin:self];
self.cameraModule = [[VICameraModule alloc] init];
self.messagingModule = [[VIMessagingModule alloc] initWithRegistrar:self.registrar];
[VIClient setVersionExtension:@"flutter-2.4.2"];
[VIClient setVersionExtension:@"flutter-2.4.3"];
}
return self;
}
Expand Down
2 changes: 1 addition & 1 deletion ios/flutter_voximplant.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
Pod::Spec.new do |s|
s.name = 'flutter_voximplant'
s.version = '2.4.2'
s.version = '2.4.3'
s.summary = 'Voximplant Flutter SDK'
s.description = <<-DESC
Voximplant plugin for embedding voice and video communication into Flutter applications.
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_voximplant
description: Voximplant plugin for embedding voice and video communication into Flutter applications.
version: 2.4.2
version: 2.4.3
authors:
- Voximplant Team <[email protected]>
- Yulia Grigorieva <[email protected]>
Expand Down

0 comments on commit abab4ff

Please sign in to comment.