Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add:针对封面适应策略的修改 #562

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
31 changes: 30 additions & 1 deletion lib/core/fijkview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ class FijkFit {
/// As large as possible while still containing the video entirely within the
/// target FijkView box. But change video's aspect ratio to 16:9.
static const FijkFit ar16_9 = FijkFit(aspectRatio: 16.0 / 9.0);

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is FijkFit &&
runtimeType == other.runtimeType &&
sizeFactor == other.sizeFactor &&
aspectRatio == other.aspectRatio &&
alignment == other.alignment;

@override
int get hashCode => Object.hash(sizeFactor, aspectRatio, alignment);
}

/// [FijkView] is a widget that can display the video frame of [FijkPlayer].
Expand Down Expand Up @@ -515,6 +527,23 @@ class __InnerFijkViewState extends State<_InnerFijkView> {
widget.fijkViewState.paramNotifier.removeListener(_fijkValueListener);
}

/// 将视频适应策略转换为 boxfit
/// convert FijkFit to BoxFit
/// this for covers fit
BoxFit _convertVideoFitToBoxFit(FijkFit originFit) {
if (originFit == FijkFit.contain) {
return BoxFit.contain;
} else if (originFit == FijkFit.fill) {
return BoxFit.fill;
} else if (originFit == FijkFit.fitWidth) {
return BoxFit.fitWidth;
} else if (originFit == FijkFit.fitHeight) {
return BoxFit.fitHeight;
} else {
return BoxFit.fitWidth;
}
}

@override
Widget build(BuildContext context) {
_panelBuilder = fView.panelBuilder;
Expand Down Expand Up @@ -557,7 +586,7 @@ class __InnerFijkViewState extends State<_InnerFijkView> {
rect: pos,
child: Image(
image: widget.cover!,
fit: BoxFit.fill,
fit: _convertVideoFitToBoxFit(_fit),
),
));
}
Expand Down