Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions lib/src/context/media_device_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ class MediaDeviceContext extends ChangeNotifier {
AudioCaptureOptions(
deviceId: selectedAudioInputDeviceId,
),
_roomCtx.enableAudioVisulizer,
);
}
selectedAudioInputDeviceId = device.deviceId;
Expand Down Expand Up @@ -138,7 +137,6 @@ class MediaDeviceContext extends ChangeNotifier {
AudioCaptureOptions(
deviceId: selectedAudioInputDeviceId,
),
_roomCtx.enableAudioVisulizer,
);
}
notifyListeners();
Expand Down Expand Up @@ -286,13 +284,10 @@ class MediaDeviceContext extends ChangeNotifier {

bool? get isSpeakerOn => Hardware.instance.speakerOn;

void setSpeakerphoneOn(bool speakerOn) async {
if (lkPlatformIs(PlatformType.iOS)) {
if (!speakerOn && Hardware.instance.preferSpeakerOutput) {
await Hardware.instance.setPreferSpeakerOutput(false);
}
}
await Hardware.instance.setSpeakerphoneOn(speakerOn);
void setSpeakerphoneOn(bool speakerOn,
{bool forceSpeakerOutput = false}) async {
await Hardware.instance
.setSpeakerphoneOn(speakerOn, forceSpeakerOutput: forceSpeakerOutput);
notifyListeners();
}

Expand Down
39 changes: 28 additions & 11 deletions lib/src/ui/widgets/track/audio_visualizer_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import '../../../context/track_reference_context.dart';
import '../theme.dart';
import 'no_track_widget.dart';

class AudioVisualizerOptions {
final int count;
class AudioVisualizerWidgetOptions {
final int barCount;
final bool centeredBands;
final double width;
final double minHeight;
final double maxHeight;
Expand All @@ -18,8 +19,9 @@ class AudioVisualizerOptions {
final double cornerRadius;
final double barMinOpacity;

const AudioVisualizerOptions({
this.count = 7,
const AudioVisualizerWidgetOptions({
this.barCount = 7,
this.centeredBands = true,
this.width = 12,
this.minHeight = 12,
this.maxHeight = 100,
Expand All @@ -32,11 +34,11 @@ class AudioVisualizerOptions {
}

class AudioVisualizerWidget extends StatelessWidget {
final AudioVisualizerOptions options;
final AudioVisualizerWidgetOptions options;

const AudioVisualizerWidget({
Key? key,
this.options = const AudioVisualizerOptions(),
this.options = const AudioVisualizerWidgetOptions(),
}) : super(key: key);

@override
Expand Down Expand Up @@ -71,13 +73,13 @@ class AudioVisualizerWidget extends StatelessWidget {
}

class SoundWaveformWidget extends StatefulWidget {
final AudioVisualizerOptions options;
final AudioVisualizerWidgetOptions options;
final AudioTrack? audioTrack;

const SoundWaveformWidget({
super.key,
this.audioTrack,
this.options = const AudioVisualizerOptions(),
this.options = const AudioVisualizerWidgetOptions(),
});

@override
Expand All @@ -88,21 +90,36 @@ class _SoundWaveformWidgetState extends State<SoundWaveformWidget>
with TickerProviderStateMixin {
late AnimationController controller;
List<double> samples = [0, 0, 0, 0, 0, 0, 0];
EventsListener<TrackEvent>? _listener;
AudioVisualizer? _visualizer;
EventsListener<AudioVisualizerEvent>? _listener;

void _startVisualizer(AudioTrack? track) async {
_listener = track?.createListener();
if (track == null) {
return;
}
samples = List.filled(widget.options.barCount, 0);
_visualizer ??= createVisualizer(track,
options: AudioVisualizerOptions(
barCount: widget.options.barCount,
centeredBands: widget.options.centeredBands));
_listener ??= _visualizer?.createListener();
_listener?.on<AudioVisualizerEvent>((e) {
if (mounted) {
setState(() {
samples = e.event.map((e) => ((e as num) * 100).toDouble()).toList();
});
}
});

await _visualizer!.start();
}

void _stopVisualizer() async {
await _visualizer?.stop();
await _visualizer?.dispose();
_visualizer = null;
await _listener?.dispose();
_listener = null;
}

@override
Expand All @@ -128,7 +145,7 @@ class _SoundWaveformWidgetState extends State<SoundWaveformWidget>

@override
Widget build(BuildContext context) {
final count = widget.options.count;
final count = widget.options.barCount;
final minHeight = widget.options.minHeight;
final maxHeight = widget.options.maxHeight;
return AnimatedBuilder(
Expand Down
64 changes: 31 additions & 33 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ dependencies:
flutter:
sdk: flutter
flutter_background: ^1.3.0+1
flutter_webrtc: ^0.12.8
flutter_webrtc: ^0.12.12+hotfix.1
google_fonts: ^6.2.1
http: ^1.2.2
intl: ^0.19.0
livekit_client: ^2.3.6
livekit_client: ^2.4.1
provider: ^6.1.2
responsive_builder: ^0.7.1

Expand All @@ -26,47 +26,45 @@ dev_dependencies:
flutter_lints: ^4.0.0
import_sorter: ^4.6.0


topics:
- webrtc
- ai
- livestream
- conference
- agent

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter packages.
# flutter:

# To add assets to your package, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
#
# For details regarding assets in packages, see
# https://flutter.dev/to/asset-from-package
#
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/to/resolution-aware-images
# To add assets to your package, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
#
# For details regarding assets in packages, see
# https://flutter.dev/to/asset-from-package
#
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/to/resolution-aware-images

# To add custom fonts to your package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts in packages, see
# https://flutter.dev/to/font-from-package
# To add custom fonts to your package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts in packages, see
# https://flutter.dev/to/font-from-package