Compare commits

...
3 Commits
Author SHA1 Message Date
edde746 adbf126430 chore: bump version 2025-11-18 13:38:45 +01:00
edde746 61817ed14e fix: subtitle cropping adjustments 2025-11-18 13:38:08 +01:00
edde746 0eff03a66e fix: macos crash 2025-11-18 13:37:39 +01:00
5 changed files with 55 additions and 88 deletions
+1 -2
View File
@@ -6,7 +6,6 @@ PODS:
- Flutter
- media_kit_video (0.0.1):
- Flutter
- media_kit_libs_ios_video
- os_media_controls (0.0.1):
- Flutter
- package_info_plus (0.4.5):
@@ -71,7 +70,7 @@ SPEC CHECKSUMS:
connectivity_plus: cb623214f4e1f6ef8fe7403d580fdad517d2f7dd
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
media_kit_libs_ios_video: 5a18affdb97d1f5d466dc79988b13eff6c5e2854
media_kit_video: 6235abf1d299037d23692ad47119b89e05346b23
media_kit_video: 1746e198cb697d1ffb734b1d05ec429d1fcd1474
os_media_controls: 86dceab6245a5325af90fc0fdebe243c42d789b4
package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499
path_provider_foundation: bb55f6dbba17d0dccd6737fe6f7f34fbd0376880
+29 -60
View File
@@ -558,87 +558,56 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen>
}
}
/// Calculate crop parameters to match what BoxFit.cover will show
Map<String, dynamic>? _calculateCropParameters() {
if (_boxFitMode != 1 || _playerSize == null || _videoSize == null) {
return null;
}
final playerAspectRatio = _playerSize!.width / _playerSize!.height;
final videoAspectRatio = _videoSize!.width / _videoSize!.height;
final playerAspect = _playerSize!.width / _playerSize!.height;
final videoAspect = _videoSize!.width / _videoSize!.height;
// No cropping needed if aspect ratios are very similar
if ((playerAspectRatio - videoAspectRatio).abs() < 0.01) {
return null;
}
if ((playerAspect - videoAspect).abs() < 0.01) return null;
int cropWidth, cropHeight, cropX, cropY;
late final int cropW, cropH, cropX, cropY;
// BoxFit.cover scales the video to fill the container, cropping the excess
// We need to crop the video to match what will actually be visible
if (videoAspectRatio > playerAspectRatio) {
// Video is wider than player - BoxFit.cover will crop horizontally
// Scale video height to match player height, then crop the width
if (videoAspect > playerAspect) {
// crop sides
final scale = _playerSize!.height / _videoSize!.height;
cropHeight = _videoSize!.height.toInt();
cropWidth = (_playerSize!.width / scale).toInt();
cropX = ((_videoSize!.width - cropWidth) / 2).toInt();
cropH = _videoSize!.height.toInt();
cropW = (_playerSize!.width / scale).toInt();
cropX = ((_videoSize!.width - cropW) ~/ 2);
cropY = 0;
} else {
// Video is taller than player - BoxFit.cover will crop vertically
// Scale video width to match player width, then crop the height
// crop top/bottom — your case
final scale = _playerSize!.width / _videoSize!.width;
cropWidth = _videoSize!.width.toInt();
cropHeight = (_playerSize!.height / scale).toInt();
cropW = _videoSize!.width.toInt();
cropH = (_playerSize!.height / scale).toInt();
cropX = 0;
cropY = ((_videoSize!.height - cropHeight) / 2).toInt();
cropY = ((_videoSize!.height - cropH) ~/ 2);
}
// Calculate subtitle margins to prevent text subtitles from appearing in cropped areas
// MPV subtitle coordinates use a normalized system where video height = 720
const double subCoordinateHeight = 720.0;
const double baseMarginY =
40.0; // Base margin from bottom edge (subtitle coordinates)
const double baseMarginX =
20.0; // Base margin from sides (subtitle coordinates)
const double kSubCoord = 720.0;
const double baseX = 20.0;
const double baseY =
45.0; // slightly larger than 40 looks better in practice
double subMarginX = baseMarginX;
double subMarginY = baseMarginY;
double subScale = 1.0; // Default scale
double extraX = cropX > 0
? (cropX / _videoSize!.width) * kSubCoord * videoAspect
: 0.0;
double extraY = cropY > 0 ? (cropY / _videoSize!.height) * kSubCoord : 0.0;
if (videoAspectRatio > playerAspectRatio) {
// Horizontal crop - need additional horizontal margins and scaling
// Convert pixel margin to subtitle coordinate system
final subCoordinateWidth = subCoordinateHeight * videoAspectRatio;
final cropMarginX = (cropX / _videoSize!.width) * subCoordinateWidth;
// Calculate scale factor first
subScale = cropWidth / _videoSize!.width;
// Apply margin accounting for scaling (scaled margins are effectively larger)
subMarginX = (baseMarginX + cropMarginX) / subScale;
} else {
// Vertical crop - need additional vertical margins and scaling
// Convert pixel margin to subtitle coordinate system
final cropMarginY = (cropY / _videoSize!.height) * subCoordinateHeight;
// Calculate scale factor first
subScale = cropHeight / _videoSize!.height;
// Apply margin accounting for scaling (scaled margins are effectively larger)
subMarginY = (baseMarginY + cropMarginY) / subScale;
}
// Only increase the margin — never shrink it
int marginX = (baseX + extraX).round();
int marginY = (baseY + extraY).round();
return {
'width': cropWidth,
'height': cropHeight,
'width': cropW,
'height': cropH,
'x': cropX,
'y': cropY,
'subMarginX': subMarginX.round(),
'subMarginY': subMarginY.round(),
'subScale': subScale,
'subMarginX': marginX,
'subMarginY': marginY,
'subScale': 1.0,
};
}
+2 -3
View File
@@ -12,7 +12,6 @@ PODS:
- FlutterMacOS
- media_kit_video (0.0.1):
- FlutterMacOS
- media_kit_libs_macos_video
- os_media_controls (0.0.1):
- FlutterMacOS
- package_info_plus (0.0.1):
@@ -99,8 +98,8 @@ SPEC CHECKSUMS:
HotKey: 400beb7caa29054ea8d864c96f5ba7e5b4852277
hotkey_manager_macos: a4317849af96d2430fa89944d3c58977ca089fbe
macos_window_utils: 23f54331a0fd51eea9e0ed347253bf48fd379d1d
media_kit_libs_macos_video: 69caff44badac986515a602bae1eb7f988a29f93
media_kit_video: 71dcfc00fc7d2e7dbe43e60b5eb505f15ab6a88e
media_kit_libs_macos_video: 85a23e549b5f480e72cae3e5634b5514bc692f65
media_kit_video: fa6564e3799a0a28bff39442334817088b7ca758
os_media_controls: c07c04c4afdf59dda0a3f398457a46823c4ce0ed
package_info_plus: f0052d280d17aa382b932f399edf32507174e870
path_provider_foundation: bb55f6dbba17d0dccd6737fe6f7f34fbd0376880
+16 -16
View File
@@ -564,8 +564,8 @@ packages:
dependency: "direct main"
description:
path: media_kit
ref: "6077829fa6705f30f85c1393a36008d5f66c06f4"
resolved-ref: "6077829fa6705f30f85c1393a36008d5f66c06f4"
ref: "3baceead40d18fd5528eaab0b4cfee4decfb4da2"
resolved-ref: "3baceead40d18fd5528eaab0b4cfee4decfb4da2"
url: "https://github.com/edde746/media-kit"
source: git
version: "1.2.1"
@@ -573,8 +573,8 @@ packages:
dependency: "direct overridden"
description:
path: "libs/android/media_kit_libs_android_video"
ref: "6077829fa6705f30f85c1393a36008d5f66c06f4"
resolved-ref: "6077829fa6705f30f85c1393a36008d5f66c06f4"
ref: "3baceead40d18fd5528eaab0b4cfee4decfb4da2"
resolved-ref: "3baceead40d18fd5528eaab0b4cfee4decfb4da2"
url: "https://github.com/edde746/media-kit"
source: git
version: "1.3.9"
@@ -582,8 +582,8 @@ packages:
dependency: "direct overridden"
description:
path: "libs/ios/media_kit_libs_ios_video"
ref: "6077829fa6705f30f85c1393a36008d5f66c06f4"
resolved-ref: "6077829fa6705f30f85c1393a36008d5f66c06f4"
ref: "3baceead40d18fd5528eaab0b4cfee4decfb4da2"
resolved-ref: "3baceead40d18fd5528eaab0b4cfee4decfb4da2"
url: "https://github.com/edde746/media-kit"
source: git
version: "1.1.4"
@@ -591,8 +591,8 @@ packages:
dependency: transitive
description:
path: "libs/linux/media_kit_libs_linux"
ref: "6077829fa6705f30f85c1393a36008d5f66c06f4"
resolved-ref: "6077829fa6705f30f85c1393a36008d5f66c06f4"
ref: "3baceead40d18fd5528eaab0b4cfee4decfb4da2"
resolved-ref: "3baceead40d18fd5528eaab0b4cfee4decfb4da2"
url: "https://github.com/edde746/media-kit"
source: git
version: "1.2.1"
@@ -600,8 +600,8 @@ packages:
dependency: "direct overridden"
description:
path: "libs/macos/media_kit_libs_macos_video"
ref: "6077829fa6705f30f85c1393a36008d5f66c06f4"
resolved-ref: "6077829fa6705f30f85c1393a36008d5f66c06f4"
ref: "3baceead40d18fd5528eaab0b4cfee4decfb4da2"
resolved-ref: "3baceead40d18fd5528eaab0b4cfee4decfb4da2"
url: "https://github.com/edde746/media-kit"
source: git
version: "1.1.5"
@@ -609,8 +609,8 @@ packages:
dependency: "direct main"
description:
path: "libs/universal/media_kit_libs_video"
ref: "6077829fa6705f30f85c1393a36008d5f66c06f4"
resolved-ref: "6077829fa6705f30f85c1393a36008d5f66c06f4"
ref: "3baceead40d18fd5528eaab0b4cfee4decfb4da2"
resolved-ref: "3baceead40d18fd5528eaab0b4cfee4decfb4da2"
url: "https://github.com/edde746/media-kit"
source: git
version: "1.0.7"
@@ -618,8 +618,8 @@ packages:
dependency: transitive
description:
path: "libs/windows/media_kit_libs_windows_video"
ref: "6077829fa6705f30f85c1393a36008d5f66c06f4"
resolved-ref: "6077829fa6705f30f85c1393a36008d5f66c06f4"
ref: "3baceead40d18fd5528eaab0b4cfee4decfb4da2"
resolved-ref: "3baceead40d18fd5528eaab0b4cfee4decfb4da2"
url: "https://github.com/edde746/media-kit"
source: git
version: "1.0.12"
@@ -627,8 +627,8 @@ packages:
dependency: "direct main"
description:
path: media_kit_video
ref: "6077829fa6705f30f85c1393a36008d5f66c06f4"
resolved-ref: "6077829fa6705f30f85c1393a36008d5f66c06f4"
ref: "3baceead40d18fd5528eaab0b4cfee4decfb4da2"
resolved-ref: "3baceead40d18fd5528eaab0b4cfee4decfb4da2"
url: "https://github.com/edde746/media-kit"
source: git
version: "1.3.1"
+7 -7
View File
@@ -1,7 +1,7 @@
name: plezy
description: "A beautiful Plex client for Flutter"
publish_to: "none"
version: 1.7.0+16
version: 1.7.1+17
environment:
sdk: ^3.8.1
@@ -39,32 +39,32 @@ dependency_overrides:
media_kit:
git:
url: https://github.com/edde746/media-kit
ref: 6077829fa6705f30f85c1393a36008d5f66c06f4
ref: 3baceead40d18fd5528eaab0b4cfee4decfb4da2
path: media_kit
media_kit_video:
git:
url: https://github.com/edde746/media-kit
ref: 6077829fa6705f30f85c1393a36008d5f66c06f4
ref: 3baceead40d18fd5528eaab0b4cfee4decfb4da2
path: media_kit_video
media_kit_libs_video:
git:
url: https://github.com/edde746/media-kit
ref: 6077829fa6705f30f85c1393a36008d5f66c06f4
ref: 3baceead40d18fd5528eaab0b4cfee4decfb4da2
path: libs/universal/media_kit_libs_video
media_kit_libs_macos_video:
git:
url: https://github.com/edde746/media-kit
ref: 6077829fa6705f30f85c1393a36008d5f66c06f4
ref: 3baceead40d18fd5528eaab0b4cfee4decfb4da2
path: libs/macos/media_kit_libs_macos_video
media_kit_libs_ios_video:
git:
url: https://github.com/edde746/media-kit
ref: 6077829fa6705f30f85c1393a36008d5f66c06f4
ref: 3baceead40d18fd5528eaab0b4cfee4decfb4da2
path: libs/ios/media_kit_libs_ios_video
media_kit_libs_android_video:
git:
url: https://github.com/edde746/media-kit
ref: 6077829fa6705f30f85c1393a36008d5f66c06f4
ref: 3baceead40d18fd5528eaab0b4cfee4decfb4da2
path: libs/android/media_kit_libs_android_video
dev_dependencies: