π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Fix: audio not playing on iOS when in silent mode
ashilkndc6fde9f77c5
diff --git a/mobile/ios/Podfile.lock b/mobile/ios/Podfile.lockindex 8ebcc2c8fe..c40e47d7ab 100644--- a/mobile/ios/Podfile.lock+++ b/mobile/ios/Podfile.lock@@ -472,7 +472,7 @@ SPEC CHECKSUMS:image_editor_common: d6f6644ae4a6de80481e89fe6d0a8c49e30b4b43image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1in_app_purchase_storekit: 0e4b3c2e43ba1e1281f4f46dd71b0593ce529892- integration_test: ce0a3ffa1de96d1a89ca0ac26fca7ea18a749ef4+ integration_test: 252f60fa39af5e17c3aa9899d35d908a0721b573libwebp: 1786c9f4ff8a279e4dac1e8f385004d5fc253009local_auth_darwin: c7e464000a6a89e952235699e32b329457608d98local_auth_ios: 5046a18c018dd973247a0564496c8898dbb5adf9diff --git a/mobile/ios/Runner/AppDelegate.swift b/mobile/ios/Runner/AppDelegate.swiftindex 9824022683..3f14877d91 100644--- a/mobile/ios/Runner/AppDelegate.swift+++ b/mobile/ios/Runner/AppDelegate.swift@@ -1,7 +1,8 @@import Flutterimport UIKit+import AVFoundation-@UIApplicationMain+@main@objc class AppDelegate: FlutterAppDelegate {override func application(_ application: UIApplication,@@ -12,11 +13,36 @@ import UIKitUNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate}+ let controller : FlutterViewController = window?.rootViewController as! FlutterViewController+ let audioSessionChannel = FlutterMethodChannel(name: "io.ente.frame/audio_session",+ binaryMessenger: controller.binaryMessenger)++ audioSessionChannel.setMethodCallHandler({+ (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in+ if call.method == "setAudioSessionCategory" {+ self.setAudioSessionCategory(result: result)+ } else {+ result(FlutterMethodNotImplemented)+ }+ })+GeneratedPluginRegistrant.register(with: self)return super.application(application, didFinishLaunchingWithOptions: launchOptions)}+ private func setAudioSessionCategory(result: @escaping FlutterResult) {+ do {+ try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default, options: [.mixWithOthers, .defaultToSpeaker])+ try AVAudioSession.sharedInstance().setActive(true)+ result(nil)+ } catch {+ result(FlutterError(code: "AUDIO_SESSION_ERROR",+ message: "Failed to set audio session category",+ details: error.localizedDescription))+ }+ }+override func applicationDidBecomeActive(_ application: UIApplication) {signal(SIGPIPE, SIG_IGN)}diff --git a/mobile/lib/audio_session_handler.dart b/mobile/lib/audio_session_handler.dartnew file mode 100644index 0000000000..8aede31b12--- /dev/null+++ b/mobile/lib/audio_session_handler.dart@@ -0,0 +1,16 @@+import "package:flutter/services.dart";+import "package:logging/logging.dart";++class AudioSessionHandler {+ static final _logger = Logger("AudioSessionHandler");+ static const MethodChannel _channel =+ MethodChannel('io.ente.frame/audio_session');++ static Future<void> setAudioSessionCategory() async {+ try {+ await _channel.invokeMethod('setAudioSessionCategory');+ } on PlatformException catch (e) {+ _logger.warning("Failed to set audio session category: '${e.message}'.");+ }+ }+}diff --git a/mobile/lib/main.dart b/mobile/lib/main.dartindex 09126649df..c2c3a38fa6 100644--- a/mobile/lib/main.dart+++ b/mobile/lib/main.dart@@ -14,6 +14,7 @@ import 'package:logging/logging.dart';import "package:media_kit/media_kit.dart";import 'package:path_provider/path_provider.dart';import 'package:photos/app.dart';+import "package:photos/audio_session_handler.dart";import 'package:photos/core/configuration.dart';import 'package:photos/core/constants.dart';import 'package:photos/core/error-reporting/super_logging.dart';@@ -73,6 +74,10 @@ const kFGTaskDeathTimeoutInMicroseconds = 5000000;void main() async {debugRepaintRainbowEnabled = false;WidgetsFlutterBinding.ensureInitialized();+ //For audio to work on vidoes in iOS when in silent mode.+ if (Platform.isIOS) {+ unawaited(AudioSessionHandler.setAudioSessionCategory());+ }MediaKit.ensureInitialized();final savedThemeMode = await AdaptiveTheme.getThemeMode();