diff --git a/assets/sounds/call.ogg b/assets/sounds/call.ogg new file mode 100644 index 00000000..63b5d4d3 Binary files /dev/null and b/assets/sounds/call.ogg differ diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index d035d315..a3ad8cc0 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'dart:io'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter/services.dart'; @@ -167,10 +166,11 @@ class ChatController extends State { void initState() { scrollController.addListener(_updateScrollController); inputFocus.addListener(_inputFocusListener); + final voipPlugin = Matrix.of(context).voipPlugin; - if (!kIsWeb) { + if (voipPlugin != null) { WidgetsBinding.instance?.addPostFrameCallback((_) { - CallKeepManager().setVoipPlugin(Matrix.of(context).voipPlugin); + CallKeepManager().setVoipPlugin(voipPlugin); CallKeepManager().initialize().catchError((_) => true); }); } @@ -819,8 +819,6 @@ class ChatController extends State { } } - bool get webrtcIsSupported => PlatformInfos.isMobile; - int? findChildIndexCallback(Key key, Map thisEventsKeyMap) { // this method is called very often. As such, it has to be optimized for speed. if (key is! ValueKey) { @@ -976,10 +974,10 @@ class ChatController extends State { final success = await showFutureLoadingDialog( context: context, future: () => - Matrix.of(context).voipPlugin.voip.requestTurnServerCredentials()); + Matrix.of(context).voipPlugin!.voip.requestTurnServerCredentials()); if (success.result != null) { final voipPlugin = Matrix.of(context).voipPlugin; - await voipPlugin.voip.inviteToCall(room!.id, callType).catchError((e) { + await voipPlugin!.voip.inviteToCall(room!.id, callType).catchError((e) { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text(e.toString()) // Text(LocalizedExceptionExtension(context, e)), diff --git a/lib/pages/chat/chat_view.dart b/lib/pages/chat/chat_view.dart index 26aba31c..b443f90b 100644 --- a/lib/pages/chat/chat_view.dart +++ b/lib/pages/chat/chat_view.dart @@ -113,7 +113,7 @@ class ChatView extends StatelessWidget { ]; } else { return [ - if (controller.webrtcIsSupported) + if (Matrix.of(context).webrtcIsSupported) IconButton( onPressed: controller.onPhoneButtonTap, icon: const Icon(Icons.call_outlined), diff --git a/lib/pages/dialer/dialer.dart b/lib/pages/dialer/dialer.dart index 829451aa..f8319d53 100644 --- a/lib/pages/dialer/dialer.dart +++ b/lib/pages/dialer/dialer.dart @@ -173,7 +173,7 @@ class _MyCallingPage extends State { CallState? _state; void _playCallSound() async { - const path = 'assets/sounds/call.wav'; + const path = 'assets/sounds/call.ogg'; if (kIsWeb) { darthtml.AudioElement() ..src = 'assets/$path' diff --git a/lib/widgets/matrix.dart b/lib/widgets/matrix.dart index 61a52ae2..f8d82665 100644 --- a/lib/widgets/matrix.dart +++ b/lib/widgets/matrix.dart @@ -83,7 +83,10 @@ class MatrixState extends State with WidgetsBindingObserver { return widget.clients[_activeClient]; } - VoipPlugin get voipPlugin => VoipPlugin(client: client, context: context); + bool get webrtcIsSupported => PlatformInfos.isMobile; + + VoipPlugin? get voipPlugin => + webrtcIsSupported ? VoipPlugin(client: client, context: context) : null; bool get isMultiAccount => widget.clients.length > 1;