mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-17 06:15:10 +00:00
feat: Convert opus to aac on iOS before playing
This commit is contained in:
parent
6a776b068d
commit
0bd61ced3f
6 changed files with 59 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
# Uncomment this line to define a global platform for your project
|
||||
platform :ios, '12.0'
|
||||
platform :ios, '12.1'
|
||||
|
||||
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
|
||||
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
|
||||
|
|
|
@ -475,7 +475,7 @@
|
|||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = iphoneos;
|
||||
|
@ -564,7 +564,7 @@
|
|||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
|
@ -613,7 +613,7 @@
|
|||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = iphoneos;
|
||||
|
|
|
@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
|
|||
|
||||
import 'package:just_audio/just_audio.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:nyx_converter/nyx_converter.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import 'package:fluffychat/utils/error_reporter.dart';
|
||||
|
@ -70,7 +71,34 @@ class AudioPlayerState extends State<AudioPlayerWidget> {
|
|||
widget.event.attachmentOrThumbnailMxcUrl()!.pathSegments.last,
|
||||
);
|
||||
file = File('${tempDir.path}/${fileName}_${matrixFile.name}');
|
||||
|
||||
await file.writeAsBytes(matrixFile.bytes);
|
||||
|
||||
if (Platform.isIOS &&
|
||||
matrixFile.mimeType.toLowerCase() == 'audio/ogg') {
|
||||
Logs().v('Convert ogg audio file for iOS...');
|
||||
final convertedFile = File('${file.path}.aac');
|
||||
if (await convertedFile.exists()) {
|
||||
file = convertedFile;
|
||||
} else {
|
||||
final completer = Completer<File>();
|
||||
NyxConverter.convertTo(
|
||||
file.path,
|
||||
tempDir.path,
|
||||
fileName: '${fileName}_${matrixFile.name}',
|
||||
container: NyxContainer.aac,
|
||||
execution: (
|
||||
String? path,
|
||||
NyxStatus status, {
|
||||
String? errorMessage,
|
||||
}) {
|
||||
if (path != null) completer.complete(File(path));
|
||||
if (errorMessage != null) completer.completeError(errorMessage);
|
||||
},
|
||||
);
|
||||
file = await completer.future;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setState(() {
|
||||
|
|
|
@ -11,6 +11,7 @@ import desktop_drop
|
|||
import device_info_plus
|
||||
import dynamic_color
|
||||
import emoji_picker_flutter
|
||||
import ffmpeg_kit_flutter_full_gpl
|
||||
import file_selector_macos
|
||||
import flutter_app_badger
|
||||
import flutter_local_notifications
|
||||
|
@ -42,6 +43,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
|||
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
||||
DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin"))
|
||||
EmojiPickerFlutterPlugin.register(with: registry.registrar(forPlugin: "EmojiPickerFlutterPlugin"))
|
||||
FFmpegKitFlutterPlugin.register(with: registry.registrar(forPlugin: "FFmpegKitFlutterPlugin"))
|
||||
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
||||
FlutterAppBadgerPlugin.register(with: registry.registrar(forPlugin: "FlutterAppBadgerPlugin"))
|
||||
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
|
||||
|
|
24
pubspec.lock
24
pubspec.lock
|
@ -385,6 +385,22 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
ffmpeg_kit_flutter_full_gpl:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: ffmpeg_kit_flutter_full_gpl
|
||||
sha256: "4f269bcb636bfcb544e5b4d65c706a3d311839970cb42638e72406410c1b5b7b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.0.3"
|
||||
ffmpeg_kit_flutter_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: ffmpeg_kit_flutter_platform_interface
|
||||
sha256: addf046ae44e190ad0101b2fde2ad909a3cd08a2a109f6106d2f7048b7abedee
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.1"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -1270,6 +1286,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
nyx_converter:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: nyx_converter
|
||||
sha256: "29684f29a650119f0417f7faa736c5b8ac65e5b32dbae40412bd6c3d7a692fc7"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.1"
|
||||
olm:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -66,6 +66,7 @@ dependencies:
|
|||
linkify: ^5.0.0
|
||||
matrix: ^0.31.0
|
||||
native_imaging: ^0.1.1
|
||||
nyx_converter: ^0.1.1
|
||||
package_info_plus: ^6.0.0
|
||||
pasteboard: ^0.2.0
|
||||
path: ^1.9.0
|
||||
|
|
Loading…
Reference in a new issue