-
-
Notifications
You must be signed in to change notification settings - Fork 47
Description
First of all, thanks for creating this wonderful package.
I'm having trouble using this package with your flutter_recorder
package, on iOS (haven't tested on Android).
If I call Recorder.instance.init()
on any point, I'm unable to play any audio using SoLoud after that point.
Calling Recorder.instance.deinit()
also doesn't work.
Here's a minimal reproducible example. "Play Sound" button doesn't work. It works when I comment out Recorder.instance.init()
.
import 'package:flutter/material.dart';
import 'package:flutter_recorder/flutter_recorder.dart';
import 'package:flutter_soloud/flutter_soloud.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await SoLoud.instance.init();
await Recorder.instance.init();
runApp(const _App());
}
class _App extends StatelessWidget {
const _App();
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
),
home: const _Page(),
);
}
}
class _Page extends StatefulWidget {
const _Page();
@override
State<_Page> createState() => _PageState();
}
class _PageState extends State<_Page> {
AudioSource? _audioSource;
@override
void initState() {
_initSound();
super.initState();
}
void _initSound() async {
_audioSource = await SoLoud.instance.loadAsset('assets/sample.mp3');
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Wrap(
alignment: WrapAlignment.center,
runAlignment: WrapAlignment.center,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
TextButton(
onPressed: () {
SoLoud.instance.play(_audioSource!);
},
child: Text('Play Sound'),
),
TextButton(
onPressed: () {
Recorder.instance.start();
Recorder.instance.startStreamingData();
},
child: Text('Start Recording(Streaming)'),
),
TextButton(
onPressed: () {
Recorder.instance.stop();
Recorder.instance.stopStreamingData();
},
child: Text('Stop Recording(Streaming)'),
),
],
),
),
);
}
}
Using the audioplayers
package with flutter_recorder
works, which I suspect it is package-specific problem. Maybe it comes from both packages using the same miniaudio engine benath the surface? I've also tried audio session management with audio_session
package, but that didn't help.
Additional Context
Using the below latest versions:
flutter_soloud: 3.1.3
flutter_recorder: 1.1.0