Skip to content

Commit

Permalink
Merge pull request #218 from takenet/develop
Browse files Browse the repository at this point in the history
Release 0.0.82
  • Loading branch information
githubdoandre authored Oct 5, 2023
2 parents e2d3409 + b463926 commit b4f2c35
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 25 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/src/controllers/chat/ds_audio_player.controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
44 changes: 22 additions & 22 deletions lib/src/widgets/chat/audio/ds_audio_player.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -106,16 +105,16 @@ class _DSAudioPlayerState extends State<DSAudioPlayer>
}

Future<void> _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(
Expand All @@ -126,14 +125,10 @@ class _DSAudioPlayerState extends State<DSAudioPlayer>
: null,
),
);

_controller.isInitialized = true;
} catch (_) {
// TODO: translate
DSToastService.error(
DSToastProps(
title: 'Erro ao reproduzir áudio',
message: 'Ops! Houve um erro ao carregar o áudio para reprodução.',
),
);
_controller.isInitialized = false;
}
}

Expand Down Expand Up @@ -182,10 +177,14 @@ class _DSAudioPlayerState extends State<DSAudioPlayer>
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(
Expand All @@ -207,8 +206,9 @@ class _DSAudioPlayerState extends State<DSAudioPlayer>
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,
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down

0 comments on commit b4f2c35

Please sign in to comment.