forked from Binozo/FlutterPlaybackCapture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayback_capture_method_channel.dart
32 lines (27 loc) · 1.08 KB
/
playback_capture_method_channel.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'data/config/audioencoding.dart';
import 'playback_capture_platform_interface.dart';
/// An implementation of [PlaybackCapturePlatform] that uses method channels.
class MethodChannelPlaybackCapture extends PlaybackCapturePlatform {
/// The method channel used to interact with the native platform.
@visibleForTesting
final methodChannel = const MethodChannel('playback_capture');
@override
Future<void> listenAudio(AudioEncoding encoding, int sampleRate, int sampleReadSize, int channelCount) async {
await methodChannel.invokeMethod("startAudioListening", {
"encoding": encoding.name,
"sample_rate": sampleRate,
"sample_read_size": sampleReadSize,
"channel_count" : channelCount
});
}
@override
Future<void> stopAudioListening() async {
await methodChannel.invokeMethod("stopAudioListening");
}
@override
Future<bool> isAudioRecordingPermissionGranted() async {
return await methodChannel.invokeMethod<bool>("audioRecordingGranted") ?? false;
}
}