Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/utils/client_manager.dart';
import 'package:fluffychat/utils/notification_background_handler.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:video_player_media_kit/video_player_media_kit.dart';
import 'config/setting_keys.dart';
import 'utils/background_push.dart';
import 'widgets/fluffy_chat_app.dart';
Expand Down Expand Up @@ -65,6 +66,14 @@ void main() async {
return;
}

// Initialize Media Kit Video Player for Desktop
if (PlatformInfos.isLinux || PlatformInfos.isWindows) {
VideoPlayerMediaKit.ensureInitialized(
linux: true,
windows: true,
);
}

// Started in foreground mode.
Logs().i(
'${AppSettings.applicationName.value} started in foreground mode. Rendering GUI...',
Expand Down
26 changes: 9 additions & 17 deletions lib/pages/chat/events/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import 'package:matrix/matrix.dart';
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/config/setting_keys.dart';
import 'package:fluffychat/utils/file_description.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/event_extension.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/utils/url_launcher.dart';
import 'package:fluffychat/widgets/blur_hash.dart';
import 'package:fluffychat/widgets/mxc_image.dart';
Expand All @@ -33,8 +31,6 @@ class EventVideoPlayer extends StatelessWidget {

@override
Widget build(BuildContext context) {
final supportsVideoPlayer = PlatformInfos.supportsVideoPlayer;

final blurHash =
(event.infoMap as Map<String, dynamic>).tryGet<String>(
'xyz.amorgan.blurhash',
Expand Down Expand Up @@ -63,16 +59,14 @@ class EventVideoPlayer extends StatelessWidget {
color: Colors.black,
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
child: InkWell(
onTap: () => supportsVideoPlayer
? showDialog(
context: context,
builder: (_) => ImageViewer(
event,
timeline: timeline,
outerContext: context,
),
)
: event.saveFile(context),
onTap: () => showDialog(
context: context,
builder: (_) => ImageViewer(
event,
timeline: timeline,
outerContext: context,
),
),
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
child: SizedBox(
width: width,
Expand Down Expand Up @@ -104,9 +98,7 @@ class EventVideoPlayer extends StatelessWidget {
),
Center(
child: CircleAvatar(
child: supportsVideoPlayer
? const Icon(Icons.play_arrow_outlined)
: const Icon(Icons.file_download_outlined),
child: const Icon(Icons.play_arrow_outlined)
Comment thread
RafayAhmad7548 marked this conversation as resolved.
),
),
if (duration != null)
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/image_viewer/image_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ImageViewerController extends State<ImageViewer> {
(event) => {
MessageTypes.Image,
MessageTypes.Sticker,
if (PlatformInfos.supportsVideoPlayer) MessageTypes.Video,
MessageTypes.Video,
}.contains(event.messageType),
)
.toList()
Expand Down
10 changes: 0 additions & 10 deletions lib/pages/image_viewer/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import 'package:universal_html/html.dart' as html;
import 'package:video_player/video_player.dart';

import 'package:fluffychat/utils/localized_exception_extension.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/event_extension.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/widgets/blur_hash.dart';
import '../../../utils/error_reporter.dart';
import '../../widgets/mxc_image.dart';
Expand All @@ -31,15 +29,7 @@ class EventVideoPlayerState extends State<EventVideoPlayer> {

double? _downloadProgress;

// The video_player package only doesn't support Windows and Linux.
final _supportsVideoPlayer =
!PlatformInfos.isWindows && !PlatformInfos.isLinux;

void _downloadAction() async {
if (!_supportsVideoPlayer) {
widget.event.saveFile(context);
return;
}

try {
final fileSize = widget.event.content
Expand Down
3 changes: 0 additions & 3 deletions lib/utils/platform_infos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ abstract class PlatformInfos {

static bool get usesTouchscreen => !isMobile;

static bool get supportsVideoPlayer =>
!PlatformInfos.isWindows && !PlatformInfos.isLinux;

/// Web could also record in theory but currently only wav which is too large
static bool get platformCanRecord => (isMobile || isMacOS);

Expand Down
8 changes: 8 additions & 0 deletions linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <flutter_webrtc/flutter_web_r_t_c_plugin.h>
#include <gtk/gtk_plugin.h>
#include <handy_window/handy_window_plugin.h>
#include <media_kit_libs_linux/media_kit_libs_linux_plugin.h>
#include <media_kit_video/media_kit_video_plugin.h>
#include <record_linux/record_linux_plugin.h>
#include <screen_retriever_linux/screen_retriever_linux_plugin.h>
#include <sqlcipher_flutter_libs/sqlite3_flutter_libs_plugin.h>
Expand Down Expand Up @@ -51,6 +53,12 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) handy_window_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "HandyWindowPlugin");
handy_window_plugin_register_with_registrar(handy_window_registrar);
g_autoptr(FlPluginRegistrar) media_kit_libs_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "MediaKitLibsLinuxPlugin");
media_kit_libs_linux_plugin_register_with_registrar(media_kit_libs_linux_registrar);
g_autoptr(FlPluginRegistrar) media_kit_video_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "MediaKitVideoPlugin");
media_kit_video_plugin_register_with_registrar(media_kit_video_registrar);
g_autoptr(FlPluginRegistrar) record_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "RecordLinuxPlugin");
record_linux_plugin_register_with_registrar(record_linux_registrar);
Expand Down
2 changes: 2 additions & 0 deletions linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ list(APPEND FLUTTER_PLUGIN_LIST
flutter_webrtc
gtk
handy_window
media_kit_libs_linux
media_kit_video
record_linux
screen_retriever_linux
sqlcipher_flutter_libs
Expand Down
2 changes: 2 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import flutter_web_auth_2
import flutter_webrtc
import geolocator_apple
import just_audio
import media_kit_video
import package_info_plus
import path_provider_foundation
import record_macos
Expand Down Expand Up @@ -53,6 +54,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FlutterWebRTCPlugin.register(with: registry.registrar(forPlugin: "FlutterWebRTCPlugin"))
GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin"))
JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin"))
MediaKitVideoPlugin.register(with: registry.registrar(forPlugin: "MediaKitVideoPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
RecordMacOsPlugin.register(with: registry.registrar(forPlugin: "RecordMacOsPlugin"))
Expand Down
56 changes: 56 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,38 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.1.0"
media_kit:
dependency: transitive
description:
name: media_kit
sha256: ae9e79597500c7ad6083a3c7b7b7544ddabfceacce7ae5c9709b0ec16a5d6643
url: "https://pub.dev"
source: hosted
version: "1.2.6"
media_kit_libs_linux:
dependency: "direct main"
description:
name: media_kit_libs_linux
sha256: "2b473399a49ec94452c4d4ae51cfc0f6585074398d74216092bf3d54aac37ecf"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
media_kit_libs_windows_video:
dependency: "direct main"
description:
name: media_kit_libs_windows_video
sha256: dff76da2778729ab650229e6b4ec6ec111eb5151431002cbd7ea304ff1f112ab
url: "https://pub.dev"
source: hosted
version: "1.0.11"
media_kit_video:
dependency: transitive
description:
name: media_kit_video
sha256: afaa509e7b7e0bf247557a3a740cde903a52c34ace9810f94500e127bd7b043d
url: "https://pub.dev"
source: hosted
version: "2.0.1"
meta:
dependency: transitive
description:
Expand Down Expand Up @@ -1500,6 +1532,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.28.0"
safe_local_storage:
dependency: transitive
description:
name: safe_local_storage
sha256: e9a21b6fec7a8aa62cc2585ff4c1b127df42f3185adbd2aca66b47abe2e80236
url: "https://pub.dev"
source: hosted
version: "2.0.1"
safe_url_check:
dependency: transitive
description:
Expand Down Expand Up @@ -1953,6 +1993,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.2.0"
uri_parser:
dependency: transitive
description:
name: uri_parser
sha256: "051c62e5f693de98ca9f130ee707f8916e2266945565926be3ff20659f7853ce"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
url_launcher:
dependency: "direct main"
description:
Expand Down Expand Up @@ -2065,6 +2113,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.7.1"
video_player_media_kit:
dependency: "direct main"
description:
name: video_player_media_kit
sha256: "66c5f30e2700f4528154320e708f89f4a80075b2451bebc6fef73a15d63a3fca"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
video_player_platform_interface:
dependency: transitive
description:
Expand Down
5 changes: 4 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ dependencies:
latlong2: ^0.9.1
linkify: ^5.0.0
matrix: ^4.1.0
media_kit_libs_linux: ^1.2.1

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has this been tested inside of a flatpak and a snap as well? Otherwise we cannot merge

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't done flatpak/snap testing.
I will test it and let you know.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to test for flatpak and it works with some additions to the flatpak manifset.
wasn't able to test snap yet, will let you know when i do

media_kit_libs_windows_video: ^1.0.11
mime: ^2.0.0
native_imaging: ^0.2.0
opus_caf_converter_dart: ^1.0.1
Expand Down Expand Up @@ -81,6 +83,7 @@ dependencies:
url_launcher: ^6.3.2
video_compress: ^3.1.4
video_player: ^2.10.1
video_player_media_kit: ^2.0.0
wakelock_plus: ^1.3.3
webrtc_interface: ^1.3.0

Expand Down Expand Up @@ -116,4 +119,4 @@ flutter:
# 1. Don't do it if you can avoid it or fix it upstream in a manageable time
# 2. Always link an (upstream?) issue
# 3. Explain how and when this can be removed (overrides must be temporarily)
dependency_overrides:
dependency_overrides:
6 changes: 6 additions & 0 deletions windows/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
#include <flutter_webrtc/flutter_web_r_t_c_plugin.h>
#include <geolocator_windows/geolocator_windows.h>
#include <media_kit_libs_windows_video/media_kit_libs_windows_video_plugin_c_api.h>
#include <media_kit_video/media_kit_video_plugin_c_api.h>
#include <permission_handler_windows/permission_handler_windows_plugin.h>
#include <record_windows/record_windows_plugin_c_api.h>
#include <screen_retriever_windows/screen_retriever_windows_plugin_c_api.h>
Expand Down Expand Up @@ -44,6 +46,10 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("FlutterWebRTCPlugin"));
GeolocatorWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("GeolocatorWindows"));
MediaKitLibsWindowsVideoPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("MediaKitLibsWindowsVideoPluginCApi"));
MediaKitVideoPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("MediaKitVideoPluginCApi"));
PermissionHandlerWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
RecordWindowsPluginCApiRegisterWithRegistrar(
Expand Down
2 changes: 2 additions & 0 deletions windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ list(APPEND FLUTTER_PLUGIN_LIST
flutter_secure_storage_windows
flutter_webrtc
geolocator_windows
media_kit_libs_windows_video
media_kit_video
permission_handler_windows
record_windows
screen_retriever_windows
Expand Down