Skip to content

Commit

Permalink
feat: Use MDK Video Backend on Linux (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdlukaa authored Sep 3, 2024
2 parents 1620304 + df1b4b1 commit 5a2271f
Show file tree
Hide file tree
Showing 21 changed files with 393 additions and 283 deletions.
18 changes: 9 additions & 9 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ import 'package:path/path.dart' as path;
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import 'package:unity_video_player/unity_video_player.dart';
import 'package:unity_video_player_flutter/unity_video_player_flutter.dart';
import 'package:unity_video_player_main/unity_video_player_main.dart';
// import 'package:unity_video_player_flutter/unity_video_player_flutter.dart';
// import 'package:unity_video_player_main/unity_video_player_main.dart';
import 'package:window_manager/window_manager.dart';

final navigatorKey = GlobalKey<NavigatorState>();
Expand All @@ -85,13 +85,13 @@ Future<void> main(List<String> args) async {
DevHttpOverrides.configureCertificates();
API.initialize();
await UnityVideoPlayerInterface.instance.initialize();
if (isDesktopPlatform && Platform.isLinux) {
if (isEmbedded) {
UnityVideoPlayerFlutterInterface.registerWith();
} else {
UnityVideoPlayerMediaKitInterface.registerWith();
}
}
// if (isDesktopPlatform && Platform.isLinux) {
// if (isEmbedded) {
// UnityVideoPlayerFlutterInterface.registerWith();
// } else {
// UnityVideoPlayerMediaKitInterface.registerWith();
// }
// }
debugPrint(UnityVideoPlayerInterface.instance.runtimeType.toString());
await configureStorage();

Expand Down
11 changes: 8 additions & 3 deletions lib/models/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,14 @@ class Server {
port: json['port'],
login: json['login'],
password: json['password'],
devices: List<Map<String, dynamic>>.from(json['devices'] as List)
.map<Device>(Device.fromJson)
.toList(),
devices: () {
if (json['devices'] == null) return <Device>[];
if ((json['devices'] as List).isEmpty) return <Device>[];
return List<Map<String, dynamic>?>.from(json['devices'] as List)
.where((element) => element != null)
.map<Device>((device) => Device.fromJson(device!))
.toList();
}(),
rtspPort: json['rtspPort'],
serverUUID: json['serverUUID'],
cookie: json['cookie'],
Expand Down
22 changes: 18 additions & 4 deletions lib/providers/settings_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:intl/intl.dart';
import 'package:unity_video_player/unity_video_player.dart';
import 'package:unity_video_player_main/unity_video_player_main.dart';

enum NetworkUsage {
auto,
Expand Down Expand Up @@ -407,8 +408,23 @@ class SettingsProvider extends UnityProvider {
loadFrom: (value) => MatrixType.values[int.parse(value)],
saveAs: (value) => value.index.toString(),
);
static bool get isHardwareZoomSupported {
if (Platform.isMacOS || kIsWeb || UpdateManager.isEmbedded) {
return false;
}

try {
if (UnityVideoPlayerInterface.instance.runtimeType !=
UnityVideoPlayerMediaKitInterface) {
return false;
}
} catch (_) {}

return true;
}

final kSoftwareZooming = _SettingsOption<bool>(
def: Platform.isMacOS || kIsWeb || UpdateManager.isEmbedded ? true : false,
def: isHardwareZoomSupported ? true : false,
key: 'other.software_zoom',
onChanged: (value) {
for (final player in UnityPlayers.players.values) {
Expand All @@ -417,9 +433,7 @@ class SettingsProvider extends UnityProvider {
..zoom.softwareZoom = value;
}
},
valueOverrider: Platform.isMacOS || kIsWeb || UpdateManager.isEmbedded
? () => true
: null,
valueOverrider: isHardwareZoomSupported ? () => true : null,
);
final kEventsMatrixedZoom = _SettingsOption(
def: true,
Expand Down
6 changes: 6 additions & 0 deletions lib/screens/events_timeline/desktop/timeline_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ class _TimelineCardState extends State<TimelineCard> {
fit: _fit ??
device.server.additionalSettings.videoFit ??
settings.kVideoFit.value,
// videoBuilder: (context, video) {
// return AspectRatio(
// aspectRatio: 16 / 9,
// child: video,
// );
// },
paneBuilder: (context, controller) {
if (currentEvent == null) {
return RepaintBoundary(
Expand Down
Loading

0 comments on commit 5a2271f

Please sign in to comment.