opt: video widget

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-03-27 10:59:12 +08:00
parent 950dd82e3c
commit 00d30313af
3 changed files with 27 additions and 36 deletions

View File

@@ -754,7 +754,7 @@ class PlPlayerController {
play: false, play: false,
); );
} else { } else {
await player.open( player.open(
Media(dataSource.videoSource!, Media(dataSource.videoSource!,
httpHeaders: dataSource.httpHeaders, start: seekTo), httpHeaders: dataSource.httpHeaders, start: seekTo),
play: false, play: false,
@@ -1564,8 +1564,7 @@ class PlPlayerController {
var pp = _videoPlayerController!.platform as NativePlayer; var pp = _videoPlayerController!.platform as NativePlayer;
await pp.setProperty('audio-files', ''); await pp.setProperty('audio-files', '');
removeListeners(); removeListeners();
await _videoPlayerController?.stop(); await _videoPlayerController!.dispose();
await _videoPlayerController?.dispose();
_videoPlayerController = null; _videoPlayerController = null;
} }
_instance = null; _instance = null;

View File

@@ -710,16 +710,23 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
key: _playerKey, key: _playerKey,
children: <Widget>[ children: <Widget>[
Obx( Obx(
() => InteractiveViewer( () => Video(
fill: widget.fill ?? Colors.black,
key: key,
alignment: widget.alignment ?? Alignment.center,
controller: videoController,
controls: NoVideoControls,
pauseUponEnteringBackgroundMode:
!plPlayerController.continuePlayInBackground.value,
resumeUponEnteringForegroundMode: true,
// 字幕尺寸调节
subtitleViewConfiguration:
plPlayerController.subtitleViewConfiguration,
fit: plPlayerController.videoFit.value,
dmWidget: widget.danmuWidget,
transformationController: transformationController, transformationController: transformationController,
panEnabled: false, // 启用平移 //单指平移会与横竖手势冲突 scaleEnabled: !plPlayerController.controlsLock.value,
scaleEnabled: !plPlayerController.controlsLock.value, // 启用缩放 enableShrinkVideoSize: plPlayerController.enableShrinkVideoSize,
minScale: plPlayerController.enableShrinkVideoSize ? 0.75 : 1,
maxScale: 2.0,
boundaryMargin: plPlayerController.enableShrinkVideoSize
? const EdgeInsets.all(double.infinity)
: EdgeInsets.zero,
panAxis: PanAxis.aligned,
onInteractionStart: (ScaleStartDetails details) { onInteractionStart: (ScaleStartDetails details) {
if (plPlayerController.controlsLock.value) return; if (plPlayerController.controlsLock.value) return;
// 如果起点太靠上则屏蔽 // 如果起点太靠上则屏蔽
@@ -731,7 +738,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
// debugPrint("_initialFocalPoint$_initialFocalPoint"); // debugPrint("_initialFocalPoint$_initialFocalPoint");
_gestureType = null; _gestureType = null;
}, },
onInteractionUpdate: (ScaleUpdateDetails details) { onInteractionUpdate: (ScaleUpdateDetails details) {
showRestoreScaleBtn.value = showRestoreScaleBtn.value =
transformationController.value.row0.x != 1.0; transformationController.value.row0.x != 1.0;
@@ -914,25 +920,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
_initialFocalPoint = Offset.zero; _initialFocalPoint = Offset.zero;
_gestureType = null; _gestureType = null;
}, },
child: Transform.flip( flipX: plPlayerController.flipX.value,
flipX: plPlayerController.flipX.value, flipY: plPlayerController.flipY.value,
flipY: plPlayerController.flipY.value,
child: Video(
fill: widget.fill ?? Colors.black,
key: key,
alignment: widget.alignment ?? Alignment.center,
controller: videoController,
controls: NoVideoControls,
pauseUponEnteringBackgroundMode:
!plPlayerController.continuePlayInBackground.value,
resumeUponEnteringForegroundMode: true,
// 字幕尺寸调节
subtitleViewConfiguration:
plPlayerController.subtitleViewConfiguration,
fit: plPlayerController.videoFit.value,
dmWidget: widget.danmuWidget,
),
),
), ),
), ),
@@ -1302,18 +1291,21 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
), ),
// if (BuildConfig.isDebug) // if (BuildConfig.isDebug)
// FilledButton.tonal( // Positioned(
// right: 25,
// top: 125,
// child: FilledButton.tonal(
// onPressed: () { // onPressed: () {
// transformationController.value = Matrix4.identity() // transformationController.value = Matrix4.identity()
// ..translate(0.5, 0.5) // ..translate(0.5, 0.5)
// ..scale(1.2) // ..scale(1.2)
// ..translate(-0.5, -0.5); // ..translate(-0.5, -0.5);
// plPlayerController.videoScale.value = // showRestoreScaleBtn.value = true;
// transformationController.value.row0.x;
// }, // },
// child: const Text('scale'), // child: const Text('scale'),
// ), // ),
// ),
Obx( Obx(
() => () =>

View File

@@ -1204,7 +1204,7 @@ packages:
description: description:
path: media_kit_video path: media_kit_video
ref: "version_1.3.0" ref: "version_1.3.0"
resolved-ref: "979051686b6a31a6aa8f7f9aa2202a86cabddeca" resolved-ref: "961752a300c67580a976874a604e4129f78a208c"
url: "https://github.com/bggRGjQaUbCoE/media-kit.git" url: "https://github.com/bggRGjQaUbCoE/media-kit.git"
source: git source: git
version: "1.3.0" version: "1.3.0"