Skip to content

Commit

Permalink
The "beeeep" is back (#4436)
Browse files Browse the repository at this point in the history
  • Loading branch information
g123k authored Aug 4, 2023
1 parent a5e1808 commit 29e2ec4
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 40 deletions.
43 changes: 20 additions & 23 deletions packages/smooth_app/lib/pages/scan/scan_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import 'package:smooth_app/data_models/user_preferences.dart';
import 'package:smooth_app/generic_lib/design_constants.dart';
import 'package:smooth_app/generic_lib/dialogs/smooth_alert_dialog.dart';
import 'package:smooth_app/generic_lib/widgets/smooth_card.dart';
import 'package:smooth_app/helpers/app_helper.dart';
import 'package:smooth_app/helpers/camera_helper.dart';
import 'package:smooth_app/helpers/haptic_feedback_helper.dart';
import 'package:smooth_app/helpers/permission_helper.dart';
Expand Down Expand Up @@ -115,7 +114,26 @@ class _ScanPageState extends State<ScanPage> {
if (_userPreferences.playCameraSound) {
await _initSoundManagerIfNecessary();
await _musicPlayer!.stop();
await _musicPlayer!.resume();
await _musicPlayer!.play(
AssetSource('audio/beep.ogg'),
volume: 0.5,
ctx: const AudioContext(
android: AudioContextAndroid(
isSpeakerphoneOn: false,
stayAwake: false,
contentType: AndroidContentType.sonification,
usageType: AndroidUsageType.notification,
audioFocus: AndroidAudioFocus.gainTransientMayDuck,
),
iOS: AudioContextIOS(
category: AVAudioSessionCategory.soloAmbient,
options: <AVAudioSessionOptions>[
AVAudioSessionOptions.mixWithOthers,
AVAudioSessionOptions.defaultToSpeaker,
],
),
),
);
}

SemanticsService.announce(
Expand All @@ -141,27 +159,6 @@ class _ScanPageState extends State<ScanPage> {
}

_musicPlayer = AudioPlayer(playerId: '1');
_musicPlayer!.audioCache.prefix = AppHelper.defaultAssetPath;
await _musicPlayer!.setSourceAsset('audio/beep.ogg');
await _musicPlayer!.setPlayerMode(PlayerMode.lowLatency);
await _musicPlayer!.setAudioContext(
const AudioContext(
android: AudioContextAndroid(
isSpeakerphoneOn: false,
stayAwake: false,
contentType: AndroidContentType.sonification,
usageType: AndroidUsageType.notificationEvent,
audioFocus: AndroidAudioFocus.gainTransientExclusive,
),
iOS: AudioContextIOS(
category: AVAudioSessionCategory.soloAmbient,
options: <AVAudioSessionOptions>[
AVAudioSessionOptions.mixWithOthers,
AVAudioSessionOptions.defaultToSpeaker,
],
),
),
);
}

Future<void> _disposeSoundManager() async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class _SmoothProductCarouselState extends State<SmoothProductCarousel> {
if (_carrouselMovingTo == null && _lastIndex != page) {
widget.onPageChangedTo?.call(
page,
page > _searchCardAdjustment
page >= _searchCardAdjustment
? barcodes[page - _searchCardAdjustment]
: null,
);
Expand Down
30 changes: 15 additions & 15 deletions packages/smooth_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -89,58 +89,58 @@ packages:
dependency: "direct main"
description:
name: audioplayers
sha256: "16451eab798b23ad9307aef6f9ca62bb8fb06542af8810eead0d236d3fd40a42"
sha256: "2f4c0da9b483b45695d01dc738e1597d7137ae40fc2fa702f13ccc10efc706a2"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
version: "5.0.0"
audioplayers_android:
dependency: transitive
description:
name: audioplayers_android
sha256: b2c833e6f718b6b030454e329931229afafe9327fdb002874dd544dc8bf2484d
sha256: "7f18bb6c7de01684444e8cba577e3c3aee0ec379897f62ad4b8259d1e22f8c61"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
version: "4.0.0"
audioplayers_darwin:
dependency: transitive
description:
name: audioplayers_darwin
sha256: e7a3c8759bf11ecfe4b20df338bf9f3d37c7719a5761c46a3833aba0ceeaacff
sha256: "80e341e6b2b364420516f2707271ec47f63b9b22766aa7f7d484601190c316a7"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
version: "5.0.0"
audioplayers_linux:
dependency: transitive
description:
name: audioplayers_linux
sha256: e95b65e1f4d4764601dac5e65f8d8186fc29401043ab020f1dacec483d708707
sha256: cca3f272c7186dd2e0025b8864e1413ac5e081d74b17e28b02ceb2df4c110235
url: "https://pub.dev"
source: hosted
version: "1.0.4"
version: "3.0.0"
audioplayers_platform_interface:
dependency: transitive
description:
name: audioplayers_platform_interface
sha256: "178581a44cb685fd798d2108111d2e98cca3400e30b9c3a05546f124fb37f600"
sha256: "47eae55e99ced11589998cf27e4eaabf5b475a7bd8bea7516ee6c2536a2e1abf"
url: "https://pub.dev"
source: hosted
version: "4.0.0"
version: "6.0.0"
audioplayers_web:
dependency: transitive
description:
name: audioplayers_web
sha256: "859ba09be2a57e57a787273f18c8cf0d9b61383870c5ee4b5632fe9adbc37edf"
sha256: "9f155590c6ba9ba469df637f4729264e4234dc3941ece4690dad63ffac19b5af"
url: "https://pub.dev"
source: hosted
version: "2.2.0"
version: "4.0.0"
audioplayers_windows:
dependency: transitive
description:
name: audioplayers_windows
sha256: "622e01c4c357c2aaf1b956c3a0f89d97c3cb40315c03f16e3b6c2a31ff9c38bc"
sha256: "8813b712ba919bb324bde5e3ba97edc81bface945953a54a3dea70b5608bcc70"
url: "https://pub.dev"
source: hosted
version: "1.1.3"
version: "3.0.0"
auto_size_text:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1764,4 +1764,4 @@ packages:
version: "3.1.2"
sdks:
dart: ">=3.0.0 <4.0.0"
flutter: ">=3.7.0-0"
flutter: ">=3.10.0"
2 changes: 1 addition & 1 deletion packages/smooth_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies:
diacritic: 0.1.3
app_store_shared:
path: ../app_store/shared
audioplayers: 3.0.1
audioplayers: 5.0.0
percent_indicator: 4.2.3
flutter_email_sender: ^6.0.0
flutter_native_splash: 2.2.19
Expand Down

0 comments on commit 29e2ec4

Please sign in to comment.