mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-14 05:03:57 +08:00
@@ -8,14 +8,12 @@ class AppBarAni extends StatelessWidget {
|
||||
required this.controller,
|
||||
required this.isTop,
|
||||
required this.isFullScreen,
|
||||
required this.removeSafeArea,
|
||||
});
|
||||
|
||||
final Widget child;
|
||||
final AnimationController controller;
|
||||
final bool isTop;
|
||||
final bool isFullScreen;
|
||||
final bool removeSafeArea;
|
||||
|
||||
static final _topPos = Tween<Offset>(
|
||||
begin: const Offset(0.0, -1.0),
|
||||
@@ -55,13 +53,11 @@ class AppBarAni extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
gradient: isTop ? _topDecoration : _bottomDecoration,
|
||||
),
|
||||
child: removeSafeArea
|
||||
? child
|
||||
: ViewSafeArea(
|
||||
left: isFullScreen,
|
||||
right: isFullScreen,
|
||||
child: child,
|
||||
),
|
||||
child: ViewSafeArea(
|
||||
left: isFullScreen,
|
||||
right: isFullScreen,
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'package:PiliPlus/common/widgets/progress_bar/audio_video_progress_bar.da
|
||||
import 'package:PiliPlus/common/widgets/progress_bar/segment_progress_bar.dart';
|
||||
import 'package:PiliPlus/pages/video/controller.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/controller.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/view/view.dart';
|
||||
import 'package:PiliPlus/utils/extension/theme_ext.dart';
|
||||
import 'package:PiliPlus/utils/platform_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -29,16 +28,14 @@ class BottomControl extends StatelessWidget {
|
||||
}
|
||||
|
||||
void onDragUpdate(ThumbDragDetails duration) {
|
||||
if (!controller.isFileSource && controller.showSeekPreview) {
|
||||
if (!controller.isFileSource) {
|
||||
controller.updatePreviewIndex(duration.timeStamp.inSeconds);
|
||||
}
|
||||
controller.onUpdatedSliderProgress(duration.timeStamp);
|
||||
}
|
||||
|
||||
void onSeek(Duration duration) {
|
||||
if (controller.showSeekPreview) {
|
||||
controller.showPreview.value = false;
|
||||
}
|
||||
controller.showPreview.value = false;
|
||||
controller
|
||||
..onChangedSliderEnd()
|
||||
..onChangedSlider(duration.inSeconds)
|
||||
@@ -100,8 +97,7 @@ class BottomControl extends StatelessWidget {
|
||||
segments: videoDetailController.segmentProgressList,
|
||||
),
|
||||
),
|
||||
if (controller.showViewPoints &&
|
||||
videoDetailController.viewPointList.isNotEmpty &&
|
||||
if (videoDetailController.viewPointList.isNotEmpty &&
|
||||
videoDetailController.showVP.value)
|
||||
Padding(
|
||||
padding: const .only(bottom: 8.75),
|
||||
@@ -113,10 +109,6 @@ class BottomControl extends StatelessWidget {
|
||||
: null,
|
||||
),
|
||||
),
|
||||
if (videoDetailController.showDmTrendChart.value)
|
||||
if (videoDetailController.dmTrend.value?.dataOrNull
|
||||
case final list?)
|
||||
buildDmChart(primary, list, videoDetailController, 4.5),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
// ignore_for_file: implementation_imports
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:PiliPlus/http/browser_ua.dart';
|
||||
import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get_rx/get_rx.dart';
|
||||
import 'package:media_kit/ffi/src/allocation.dart';
|
||||
import 'package:media_kit/ffi/src/utf8.dart';
|
||||
import 'package:media_kit/generated/libmpv/bindings.dart' as generated;
|
||||
import 'package:media_kit/media_kit.dart';
|
||||
import 'package:media_kit/src/player/native/core/initializer.dart';
|
||||
|
||||
class MpvConvertWebp {
|
||||
final _mpv = NativePlayer.mpv;
|
||||
late final Pointer<generated.mpv_handle> _ctx;
|
||||
final _completer = Completer<bool>();
|
||||
|
||||
bool _success = false;
|
||||
|
||||
final String url;
|
||||
final String outFile;
|
||||
final double start;
|
||||
final double duration;
|
||||
final RxDouble? progress;
|
||||
final WebpPreset preset;
|
||||
|
||||
MpvConvertWebp(
|
||||
this.url,
|
||||
this.outFile,
|
||||
this.start,
|
||||
double end, {
|
||||
this.progress,
|
||||
this.preset = WebpPreset.def,
|
||||
}) : duration = end - start;
|
||||
|
||||
Future<void> _init() async {
|
||||
final enableHA = Pref.enableHA;
|
||||
_ctx = await Initializer.create(
|
||||
_mpv,
|
||||
_onEvent,
|
||||
options: {
|
||||
'o': outFile,
|
||||
'start': start.toStringAsFixed(3),
|
||||
'end': (start + duration).toStringAsFixed(3),
|
||||
'of': 'webp',
|
||||
'ovc': 'libwebp_anim',
|
||||
'ofopts': 'loop=0',
|
||||
'ovcopts': 'preset=${preset.flag}',
|
||||
if (enableHA) 'vo': 'gpu',
|
||||
if (enableHA)
|
||||
'hwdec':
|
||||
'${Pref.hardwareDecoding},auto-copy', // transcode only support copy
|
||||
},
|
||||
);
|
||||
NativePlayer.setHeader(
|
||||
_mpv,
|
||||
_ctx,
|
||||
userAgent: BrowserUa.pc,
|
||||
referer: HttpString.baseUrl,
|
||||
);
|
||||
if (progress != null) {
|
||||
_observeProperty('time-pos');
|
||||
}
|
||||
final level = (kDebugMode ? 'info' : 'error').toNativeUtf8();
|
||||
_mpv.mpv_request_log_messages(_ctx, level);
|
||||
calloc.free(level);
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
Initializer.dispose(_ctx);
|
||||
_mpv.mpv_terminate_destroy(_ctx);
|
||||
if (!_completer.isCompleted) _completer.complete(false);
|
||||
}
|
||||
|
||||
Future<bool> convert() async {
|
||||
await _init();
|
||||
_command(['loadfile', url]);
|
||||
return _completer.future;
|
||||
}
|
||||
|
||||
Future<void>? _onEvent(Pointer<generated.mpv_event> event) {
|
||||
switch (event.ref.event_id) {
|
||||
case generated.mpv_event_id.MPV_EVENT_PROPERTY_CHANGE:
|
||||
final prop = event.ref.data.cast<generated.mpv_event_property>().ref;
|
||||
if (prop.name.toDartString() == 'time-pos' &&
|
||||
prop.format == generated.mpv_format.MPV_FORMAT_DOUBLE) {
|
||||
progress!.value = (prop.data.cast<Double>().value - start) / duration;
|
||||
}
|
||||
break;
|
||||
case generated.mpv_event_id.MPV_EVENT_FILE_LOADED:
|
||||
_success = true;
|
||||
break;
|
||||
case generated.mpv_event_id.MPV_EVENT_LOG_MESSAGE:
|
||||
final log = event.ref.data.cast<generated.mpv_event_log_message>().ref;
|
||||
final prefix = log.prefix.toDartString().trim();
|
||||
final level = log.level.toDartString().trim();
|
||||
final text = log.text.toDartString().trim();
|
||||
debugPrint('WebpConvert: $level $prefix : $text');
|
||||
if (kDebugMode) {
|
||||
if (level == 'error' || level == 'fatal') _success = false;
|
||||
} else {
|
||||
_success = false;
|
||||
}
|
||||
break;
|
||||
case generated.mpv_event_id.MPV_EVENT_END_FILE ||
|
||||
generated.mpv_event_id.MPV_EVENT_SHUTDOWN:
|
||||
progress?.value = 1;
|
||||
_completer.complete(_success);
|
||||
dispose();
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void _command(List<String> args) {
|
||||
final pointers = args.map((e) => e.toNativeUtf8()).toList();
|
||||
final arr = calloc<Pointer<Uint8>>(pointers.length + 1);
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
arr[i] = pointers[i];
|
||||
}
|
||||
|
||||
_mpv.mpv_command(_ctx, arr);
|
||||
|
||||
calloc.free(arr);
|
||||
pointers.forEach(calloc.free);
|
||||
}
|
||||
|
||||
void _observeProperty(String property) {
|
||||
final name = property.toNativeUtf8();
|
||||
_mpv.mpv_observe_property(
|
||||
_ctx,
|
||||
property.hashCode,
|
||||
name,
|
||||
generated.mpv_format.MPV_FORMAT_DOUBLE,
|
||||
);
|
||||
|
||||
calloc.free(name);
|
||||
}
|
||||
}
|
||||
|
||||
enum WebpPreset {
|
||||
none('none', '无', '不使用预设'),
|
||||
def('default', '默认', '默认预设'),
|
||||
picture('picture', '图片', '数码照片,如人像、室内拍摄'),
|
||||
photo('photo', '照片', '户外摄影,自然光环境'),
|
||||
drawing('drawing', '绘图', '手绘或线稿,高对比度细节'),
|
||||
icon('icon', '图标', '小型彩色图像'),
|
||||
text('text', '文本', '文字类'),
|
||||
;
|
||||
|
||||
final String flag;
|
||||
final String name;
|
||||
final String desc;
|
||||
|
||||
const WebpPreset(this.flag, this.name, this.desc);
|
||||
}
|
||||
Reference in New Issue
Block a user