39 lines
1013 B
Dart
39 lines
1013 B
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
class SCVoiceRoomForegroundService {
|
|
static const MethodChannel _channel = MethodChannel(
|
|
'com.org.yumiparty/voice_room_foreground_service',
|
|
);
|
|
|
|
static Future<void> start({String? roomName}) async {
|
|
if (!Platform.isAndroid) {
|
|
return;
|
|
}
|
|
try {
|
|
await _channel.invokeMethod<void>('start', {
|
|
'roomName': roomName?.trim(),
|
|
});
|
|
} on PlatformException catch (e) {
|
|
debugPrint('[VoiceRoomForeground] start failed: ${e.message}');
|
|
} catch (e) {
|
|
debugPrint('[VoiceRoomForeground] start failed: $e');
|
|
}
|
|
}
|
|
|
|
static Future<void> stop() async {
|
|
if (!Platform.isAndroid) {
|
|
return;
|
|
}
|
|
try {
|
|
await _channel.invokeMethod<void>('stop');
|
|
} on PlatformException catch (e) {
|
|
debugPrint('[VoiceRoomForeground] stop failed: ${e.message}');
|
|
} catch (e) {
|
|
debugPrint('[VoiceRoomForeground] stop failed: $e');
|
|
}
|
|
}
|
|
}
|