From cd8fd5ca17c4ba178eb6f37097844bc48b099b8d Mon Sep 17 00:00:00 2001 From: Marcelo Amaro Date: Mon, 25 Sep 2023 09:37:15 -0300 Subject: [PATCH 1/4] build: add merge github actions workflow --- .github/workflows/merge.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/merge.yml diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml new file mode 100644 index 00000000..c6905df0 --- /dev/null +++ b/.github/workflows/merge.yml @@ -0,0 +1,20 @@ +name: Merge + +on: + push: + branches: [main] + workflow_dispatch: + +jobs: + merge-main-to-develop: + name: Merge main back to develop + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Merge command + run: | + git fetch + git checkout develop + git pull + git merge main -m "build: merge main back to develop" + git push \ No newline at end of file From 9074f894cbbe07a474efdb5885c854b688c03f6d Mon Sep 17 00:00:00 2001 From: Andre Rossi Date: Mon, 2 Oct 2023 17:07:38 -0300 Subject: [PATCH 2/4] fix: fixed dispose of the player --- lib/src/widgets/chat/audio/ds_audio_player.widget.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/src/widgets/chat/audio/ds_audio_player.widget.dart b/lib/src/widgets/chat/audio/ds_audio_player.widget.dart index af8e24e6..c9cee87e 100644 --- a/lib/src/widgets/chat/audio/ds_audio_player.widget.dart +++ b/lib/src/widgets/chat/audio/ds_audio_player.widget.dart @@ -63,7 +63,10 @@ class _DSAudioPlayerState extends State @override void dispose() { - _controller.player.dispose(); + if (_controller.player.playerState.processingState != + ProcessingState.idle) { + _controller.player.dispose(); + } _controller.dispose(); super.dispose(); } @@ -126,8 +129,8 @@ class _DSAudioPlayerState extends State : null, ), ); - } catch (_) { - // TODO: translate + } on PlayerInterruptedException catch (_) { + } catch (e) { DSToastService.error( DSToastProps( title: 'Erro ao reproduzir áudio', From 5571999ed2efa8f0ed6fabcc7b8b4426146c3877 Mon Sep 17 00:00:00 2001 From: Andre Rossi Date: Tue, 3 Oct 2023 15:39:58 -0300 Subject: [PATCH 3/4] feat: disabled player when there is an error --- .../chat/ds_audio_player.controller.dart | 3 +- .../chat/audio/ds_audio_player.widget.dart | 51 +++++++++---------- pubspec.yaml | 2 +- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/lib/src/controllers/chat/ds_audio_player.controller.dart b/lib/src/controllers/chat/ds_audio_player.controller.dart index b407eda6..df88bad7 100644 --- a/lib/src/controllers/chat/ds_audio_player.controller.dart +++ b/lib/src/controllers/chat/ds_audio_player.controller.dart @@ -4,9 +4,10 @@ import 'package:rxdart/rxdart.dart' as rx_dart; class DSAudioPlayerController extends GetxController { final audioSpeed = RxDouble(1.0); - final player = AudioPlayer(); + bool isInitialized = false; + /// Collects the data useful for displaying in a SeekBar widget. /// /// Uses a useful feature of rx_dart to combine the 3 streams of interest into one. diff --git a/lib/src/widgets/chat/audio/ds_audio_player.widget.dart b/lib/src/widgets/chat/audio/ds_audio_player.widget.dart index a0e8e1b7..7ad7d55b 100644 --- a/lib/src/widgets/chat/audio/ds_audio_player.widget.dart +++ b/lib/src/widgets/chat/audio/ds_audio_player.widget.dart @@ -8,10 +8,9 @@ import 'package:just_audio/just_audio.dart'; import 'package:path_provider/path_provider.dart'; import '../../../controllers/chat/ds_audio_player.controller.dart'; -import '../../../models/ds_toast_props.model.dart'; import '../../../services/ds_auth.service.dart'; import '../../../services/ds_file.service.dart'; -import '../../../services/ds_toast.service.dart'; +import '../../../themes/colors/ds_colors.theme.dart'; import '../../buttons/ds_pause_button.widget.dart'; import '../../buttons/ds_play_button.widget.dart'; import 'ds_audio_seek_bar.widget.dart'; @@ -63,10 +62,7 @@ class _DSAudioPlayerState extends State @override void dispose() { - if (_controller.player.playerState.processingState != - ProcessingState.idle) { - _controller.player.dispose(); - } + _controller.player.dispose(); _controller.dispose(); super.dispose(); } @@ -109,16 +105,16 @@ class _DSAudioPlayerState extends State } Future _init() async { - try { - _controller.player.playerStateStream.listen( - (event) { - if (event.processingState == ProcessingState.completed) { - _controller.player.seek(Duration.zero); - _controller.player.stop(); - } - }, - ); + _controller.player.playerStateStream.listen( + (event) { + if (event.processingState == ProcessingState.completed) { + _controller.player.seek(Duration.zero); + _controller.player.stop(); + } + }, + ); + try { Platform.isIOS && widget.audioType.contains('ogg') ? await _transcoder() : await _controller.player.setAudioSource( @@ -129,14 +125,10 @@ class _DSAudioPlayerState extends State : null, ), ); - } on PlayerInterruptedException catch (_) { - } catch (e) { - DSToastService.error( - DSToastProps( - title: 'Erro ao reproduzir áudio', - message: 'Ops! Houve um erro ao carregar o áudio para reprodução.', - ), - ); + + _controller.isInitialized = true; + } catch (_) { + _controller.isInitialized = false; } } @@ -185,10 +177,14 @@ class _DSAudioPlayerState extends State final playing = playerState?.playing; if (playing != true) { return DSPlayButton( - onPressed: _controller.player.play, + onPressed: _controller.isInitialized + ? _controller.player.play + : () => {}, isLoading: [ProcessingState.loading, ProcessingState.buffering] .contains(processingState), - color: widget.controlForegroundColor, + color: _controller.isInitialized + ? widget.controlForegroundColor + : DSColors.contentDisable, ); } else if (processingState != ProcessingState.completed) { return DSPauseButton( @@ -210,8 +206,9 @@ class _DSAudioPlayerState extends State duration: positionData?.duration ?? Duration.zero, position: positionData?.position ?? Duration.zero, bufferedPosition: positionData?.bufferedPosition ?? Duration.zero, - onChangeEnd: _controller.player.play, - onChanged: _controller.player.seek, + onChangeEnd: + _controller.isInitialized ? _controller.player.play : null, + onChanged: _controller.isInitialized ? _controller.player.seek : null, onChangeStart: _controller.player.pause, labelColor: widget.labelColor, bufferActiveTrackColor: widget.bufferActiveTrackColor, diff --git a/pubspec.yaml b/pubspec.yaml index 2dd99891..48431d92 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: flutter: sdk: flutter ffmpeg_kit_flutter_full_gpl: ^5.1.0 - just_audio: ^0.9.30 + just_audio: ^0.9.35 rxdart: ^0.27.4 flutter_spinkit: ^5.1.0 get: ^4.6.5 From b4639261557d08b15cee9822cd183cb3a2426093 Mon Sep 17 00:00:00 2001 From: Andre Rossi Date: Thu, 5 Oct 2023 09:41:47 -0300 Subject: [PATCH 4/4] chore: update version --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e87b996..9be3b8ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.0.82 + +- [DSAudioPlayer] Improved the audio player initialization + ## 0.0.81 - [FFMPEG] Downgraded ffmpeg dependency version from 6.0.2 to 5.1.0 diff --git a/pubspec.yaml b/pubspec.yaml index 48431d92..721f6849 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: blip_ds description: Blip Design System for Flutter. -version: 0.0.81 +version: 0.0.82 homepage: https://github.com/takenet/blip-ds-flutter#readme repository: https://github.com/takenet/blip-ds-flutter