mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-29 15:00:14 +08:00
opt player keyboard event
opt triple opt desktop pip Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -9,6 +9,7 @@ import 'package:PiliPlus/models_new/fav/fav_folder/data.dart';
|
|||||||
import 'package:PiliPlus/models_new/video/video_detail/data.dart';
|
import 'package:PiliPlus/models_new/video/video_detail/data.dart';
|
||||||
import 'package:PiliPlus/models_new/video/video_detail/stat_detail.dart';
|
import 'package:PiliPlus/models_new/video/video_detail/stat_detail.dart';
|
||||||
import 'package:PiliPlus/models_new/video/video_tag/data.dart';
|
import 'package:PiliPlus/models_new/video/video_tag/data.dart';
|
||||||
|
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/triple_mixin.dart';
|
||||||
import 'package:PiliPlus/services/account_service.dart';
|
import 'package:PiliPlus/services/account_service.dart';
|
||||||
import 'package:PiliPlus/utils/global_data.dart';
|
import 'package:PiliPlus/utils/global_data.dart';
|
||||||
import 'package:PiliPlus/utils/id_utils.dart';
|
import 'package:PiliPlus/utils/id_utils.dart';
|
||||||
@@ -21,25 +22,16 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
abstract class CommonIntroController extends GetxController {
|
abstract class CommonIntroController extends GetxController
|
||||||
|
with GetSingleTickerProviderStateMixin, TripleMixin {
|
||||||
late final String heroTag;
|
late final String heroTag;
|
||||||
late String bvid;
|
late String bvid;
|
||||||
|
|
||||||
// 是否点赞
|
|
||||||
final RxBool hasLike = false.obs;
|
|
||||||
// 投币数量
|
|
||||||
final RxNum coinNum = RxNum(0);
|
|
||||||
// 是否投币
|
|
||||||
bool get hasCoin => coinNum.value != 0;
|
|
||||||
// 是否收藏
|
|
||||||
final RxBool hasFav = false.obs;
|
|
||||||
// 是否稍后再看
|
// 是否稍后再看
|
||||||
final RxBool hasLater = false.obs;
|
final RxBool hasLater = false.obs;
|
||||||
|
|
||||||
final Rx<List<VideoTagItem>?> videoTags = Rx<List<VideoTagItem>?>(null);
|
final Rx<List<VideoTagItem>?> videoTags = Rx<List<VideoTagItem>?>(null);
|
||||||
|
|
||||||
bool get hasTriple => hasLike.value && hasCoin && hasFav.value;
|
|
||||||
|
|
||||||
bool isProcessing = false;
|
bool isProcessing = false;
|
||||||
Future<void> handleAction(FutureOr Function() action) async {
|
Future<void> handleAction(FutureOr Function() action) async {
|
||||||
if (!isProcessing) {
|
if (!isProcessing) {
|
||||||
@@ -65,9 +57,7 @@ abstract class CommonIntroController extends GetxController {
|
|||||||
bool prevPlay();
|
bool prevPlay();
|
||||||
bool nextPlay();
|
bool nextPlay();
|
||||||
|
|
||||||
Future<void> actionLikeVideo();
|
|
||||||
void actionCoinVideo();
|
void actionCoinVideo();
|
||||||
void actionTriple();
|
|
||||||
void actionShareVideo(BuildContext context);
|
void actionShareVideo(BuildContext context);
|
||||||
|
|
||||||
// 同时观看
|
// 同时观看
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import 'package:PiliPlus/pages/video/controller.dart';
|
|||||||
import 'package:PiliPlus/pages/video/introduction/pgc/controller.dart';
|
import 'package:PiliPlus/pages/video/introduction/pgc/controller.dart';
|
||||||
import 'package:PiliPlus/pages/video/introduction/pgc/widgets/pgc_panel.dart';
|
import 'package:PiliPlus/pages/video/introduction/pgc/widgets/pgc_panel.dart';
|
||||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/action_item.dart';
|
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/action_item.dart';
|
||||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/triple_state.dart';
|
|
||||||
import 'package:PiliPlus/utils/extension.dart';
|
import 'package:PiliPlus/utils/extension.dart';
|
||||||
import 'package:PiliPlus/utils/num_utils.dart';
|
import 'package:PiliPlus/utils/num_utils.dart';
|
||||||
import 'package:PiliPlus/utils/page_utils.dart';
|
import 'package:PiliPlus/utils/page_utils.dart';
|
||||||
@@ -44,8 +43,7 @@ class PgcIntroPage extends StatefulWidget {
|
|||||||
State<PgcIntroPage> createState() => _PgcIntroPageState();
|
State<PgcIntroPage> createState() => _PgcIntroPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PgcIntroPageState extends TripleState<PgcIntroPage> {
|
class _PgcIntroPageState extends State<PgcIntroPage> {
|
||||||
@override
|
|
||||||
late final PgcIntroController introController;
|
late final PgcIntroController introController;
|
||||||
late final VideoDetailController videoDetailCtr;
|
late final VideoDetailController videoDetailCtr;
|
||||||
|
|
||||||
@@ -412,19 +410,19 @@ class _PgcIntroPageState extends TripleState<PgcIntroPage> {
|
|||||||
children: [
|
children: [
|
||||||
Obx(
|
Obx(
|
||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
animation: tripleAnimation,
|
animation: introController.tripleAnimation,
|
||||||
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
||||||
selectStatus: introController.hasLike.value,
|
selectStatus: introController.hasLike.value,
|
||||||
semanticsLabel: '点赞',
|
semanticsLabel: '点赞',
|
||||||
text: NumUtils.numFormat(item.stat!.like),
|
text: NumUtils.numFormat(item.stat!.like),
|
||||||
onStartTriple: onStartTriple,
|
onStartTriple: introController.onStartTriple,
|
||||||
onCancelTriple: onCancelTriple,
|
onCancelTriple: introController.onCancelTriple,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Obx(
|
Obx(
|
||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
animation: tripleAnimation,
|
animation: introController.tripleAnimation,
|
||||||
icon: const Icon(FontAwesomeIcons.b),
|
icon: const Icon(FontAwesomeIcons.b),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.b),
|
selectIcon: const Icon(FontAwesomeIcons.b),
|
||||||
onTap: introController.actionCoinVideo,
|
onTap: introController.actionCoinVideo,
|
||||||
@@ -435,7 +433,7 @@ class _PgcIntroPageState extends TripleState<PgcIntroPage> {
|
|||||||
),
|
),
|
||||||
Obx(
|
Obx(
|
||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
animation: tripleAnimation,
|
animation: introController.tripleAnimation,
|
||||||
icon: const Icon(FontAwesomeIcons.star),
|
icon: const Icon(FontAwesomeIcons.star),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.solidStar),
|
selectIcon: const Icon(FontAwesomeIcons.solidStar),
|
||||||
onTap: () => introController.showFavBottomSheet(context),
|
onTap: () => introController.showFavBottomSheet(context),
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import 'package:PiliPlus/pages/video/introduction/ugc/widgets/action_item.dart';
|
|||||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/page.dart';
|
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/page.dart';
|
||||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/season.dart';
|
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/season.dart';
|
||||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/selectable_text.dart';
|
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/selectable_text.dart';
|
||||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/triple_state.dart';
|
|
||||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||||
import 'package:PiliPlus/utils/date_utils.dart';
|
import 'package:PiliPlus/utils/date_utils.dart';
|
||||||
import 'package:PiliPlus/utils/extension.dart';
|
import 'package:PiliPlus/utils/extension.dart';
|
||||||
@@ -55,8 +54,7 @@ class UgcIntroPanel extends StatefulWidget {
|
|||||||
State<UgcIntroPanel> createState() => _UgcIntroPanelState();
|
State<UgcIntroPanel> createState() => _UgcIntroPanelState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _UgcIntroPanelState extends TripleState<UgcIntroPanel> {
|
class _UgcIntroPanelState extends State<UgcIntroPanel> {
|
||||||
@override
|
|
||||||
late final UgcIntroController introController;
|
late final UgcIntroController introController;
|
||||||
late final VideoDetailController videoDetailCtr =
|
late final VideoDetailController videoDetailCtr =
|
||||||
Get.find<VideoDetailController>(tag: widget.heroTag);
|
Get.find<VideoDetailController>(tag: widget.heroTag);
|
||||||
@@ -514,7 +512,7 @@ class _UgcIntroPanelState extends TripleState<UgcIntroPanel> {
|
|||||||
children: [
|
children: [
|
||||||
Obx(
|
Obx(
|
||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
animation: tripleAnimation,
|
animation: introController.tripleAnimation,
|
||||||
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
||||||
selectStatus: introController.hasLike.value,
|
selectStatus: introController.hasLike.value,
|
||||||
@@ -522,8 +520,8 @@ class _UgcIntroPanelState extends TripleState<UgcIntroPanel> {
|
|||||||
text: !isLoading
|
text: !isLoading
|
||||||
? NumUtils.numFormat(videoDetail.stat!.like)
|
? NumUtils.numFormat(videoDetail.stat!.like)
|
||||||
: null,
|
: null,
|
||||||
onStartTriple: onStartTriple,
|
onStartTriple: introController.onStartTriple,
|
||||||
onCancelTriple: onCancelTriple,
|
onCancelTriple: introController.onCancelTriple,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Obx(
|
Obx(
|
||||||
@@ -540,7 +538,7 @@ class _UgcIntroPanelState extends TripleState<UgcIntroPanel> {
|
|||||||
),
|
),
|
||||||
Obx(
|
Obx(
|
||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
animation: tripleAnimation,
|
animation: introController.tripleAnimation,
|
||||||
icon: const Icon(FontAwesomeIcons.b),
|
icon: const Icon(FontAwesomeIcons.b),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.b),
|
selectIcon: const Icon(FontAwesomeIcons.b),
|
||||||
onTap: introController.actionCoinVideo,
|
onTap: introController.actionCoinVideo,
|
||||||
@@ -553,7 +551,7 @@ class _UgcIntroPanelState extends TripleState<UgcIntroPanel> {
|
|||||||
),
|
),
|
||||||
Obx(
|
Obx(
|
||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
animation: tripleAnimation,
|
animation: introController.tripleAnimation,
|
||||||
icon: const Icon(FontAwesomeIcons.star),
|
icon: const Icon(FontAwesomeIcons.star),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.solidStar),
|
selectIcon: const Icon(FontAwesomeIcons.solidStar),
|
||||||
onTap: () => introController.showFavBottomSheet(context),
|
onTap: () => introController.showFavBottomSheet(context),
|
||||||
|
|||||||
@@ -1,15 +1,26 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:math' show pi;
|
import 'dart:math' show pi;
|
||||||
|
|
||||||
import 'package:PiliPlus/pages/common/common_intro_controller.dart';
|
|
||||||
import 'package:PiliPlus/utils/utils.dart';
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
abstract class TripleState<T extends StatefulWidget> extends State<T>
|
mixin TripleMixin on GetxController, TickerProvider {
|
||||||
with SingleTickerProviderStateMixin {
|
// 是否点赞
|
||||||
CommonIntroController get introController;
|
final RxBool hasLike = false.obs;
|
||||||
|
// 投币数量
|
||||||
|
final RxNum coinNum = RxNum(0);
|
||||||
|
// 是否投币
|
||||||
|
bool get hasCoin => coinNum.value != 0;
|
||||||
|
// 是否收藏
|
||||||
|
final RxBool hasFav = false.obs;
|
||||||
|
|
||||||
|
bool get hasTriple => hasLike.value && hasCoin && hasFav.value;
|
||||||
|
|
||||||
|
void actionTriple();
|
||||||
|
Future<void> actionLikeVideo();
|
||||||
|
|
||||||
// no need for pugv
|
// no need for pugv
|
||||||
AnimationController? _tripleAnimCtr;
|
AnimationController? _tripleAnimCtr;
|
||||||
@@ -34,13 +45,6 @@ abstract class TripleState<T extends StatefulWidget> extends State<T>
|
|||||||
_timer = null;
|
_timer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_cancelTimer();
|
|
||||||
_tripleAnimCtr?.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
static final _duration = Utils.isMobile
|
static final _duration = Utils.isMobile
|
||||||
? const Duration(milliseconds: 200)
|
? const Duration(milliseconds: 200)
|
||||||
: const Duration(milliseconds: 230);
|
: const Duration(milliseconds: 230);
|
||||||
@@ -48,12 +52,12 @@ abstract class TripleState<T extends StatefulWidget> extends State<T>
|
|||||||
void onStartTriple() {
|
void onStartTriple() {
|
||||||
_timer ??= Timer(_duration, () {
|
_timer ??= Timer(_duration, () {
|
||||||
HapticFeedback.lightImpact();
|
HapticFeedback.lightImpact();
|
||||||
if (introController.hasTriple) {
|
if (hasTriple) {
|
||||||
SmartDialog.showToast('已完成三连');
|
SmartDialog.showToast('已完成三连');
|
||||||
} else {
|
} else {
|
||||||
tripleAnimCtr.forward().whenComplete(() {
|
tripleAnimCtr.forward().whenComplete(() {
|
||||||
tripleAnimCtr.reset();
|
tripleAnimCtr.reset();
|
||||||
introController.actionTriple();
|
actionTriple();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
_cancelTimer();
|
_cancelTimer();
|
||||||
@@ -66,8 +70,15 @@ abstract class TripleState<T extends StatefulWidget> extends State<T>
|
|||||||
} else if (_timer != null && _timer!.tick == 0) {
|
} else if (_timer != null && _timer!.tick == 0) {
|
||||||
_cancelTimer();
|
_cancelTimer();
|
||||||
if (isTapUp) {
|
if (isTapUp) {
|
||||||
introController.actionLikeVideo();
|
actionLikeVideo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onClose() {
|
||||||
|
_cancelTimer();
|
||||||
|
_tripleAnimCtr?.dispose();
|
||||||
|
super.onClose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,6 @@ import 'package:PiliPlus/pages/video/introduction/pgc/controller.dart';
|
|||||||
import 'package:PiliPlus/pages/video/introduction/ugc/controller.dart';
|
import 'package:PiliPlus/pages/video/introduction/ugc/controller.dart';
|
||||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/action_item.dart';
|
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/action_item.dart';
|
||||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/menu_row.dart';
|
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/menu_row.dart';
|
||||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/triple_state.dart';
|
|
||||||
import 'package:PiliPlus/plugin/pl_player/controller.dart';
|
import 'package:PiliPlus/plugin/pl_player/controller.dart';
|
||||||
import 'package:PiliPlus/plugin/pl_player/models/play_repeat.dart';
|
import 'package:PiliPlus/plugin/pl_player/models/play_repeat.dart';
|
||||||
import 'package:PiliPlus/plugin/pl_player/utils/fullscreen.dart';
|
import 'package:PiliPlus/plugin/pl_player/utils/fullscreen.dart';
|
||||||
@@ -64,7 +63,7 @@ class HeaderControl extends StatefulWidget {
|
|||||||
State<HeaderControl> createState() => HeaderControlState();
|
State<HeaderControl> createState() => HeaderControlState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class HeaderControlState extends TripleState<HeaderControl> {
|
class HeaderControlState extends State<HeaderControl> {
|
||||||
late final PlPlayerController plPlayerController = widget.controller;
|
late final PlPlayerController plPlayerController = widget.controller;
|
||||||
late final VideoDetailController videoDetailCtr = widget.videoDetailCtr;
|
late final VideoDetailController videoDetailCtr = widget.videoDetailCtr;
|
||||||
late final PlayUrlModel videoInfo = videoDetailCtr.data;
|
late final PlayUrlModel videoInfo = videoDetailCtr.data;
|
||||||
@@ -74,7 +73,6 @@ class HeaderControlState extends TripleState<HeaderControl> {
|
|||||||
String get heroTag => widget.heroTag;
|
String get heroTag => widget.heroTag;
|
||||||
late final UgcIntroController ugcIntroController;
|
late final UgcIntroController ugcIntroController;
|
||||||
late final PgcIntroController pgcIntroController;
|
late final PgcIntroController pgcIntroController;
|
||||||
@override
|
|
||||||
late CommonIntroController introController = videoDetailCtr.isUgc
|
late CommonIntroController introController = videoDetailCtr.isUgc
|
||||||
? ugcIntroController
|
? ugcIntroController
|
||||||
: pgcIntroController;
|
: pgcIntroController;
|
||||||
@@ -2289,16 +2287,16 @@ class HeaderControlState extends TripleState<HeaderControl> {
|
|||||||
),
|
),
|
||||||
selectStatus: introController.hasLike.value,
|
selectStatus: introController.hasLike.value,
|
||||||
semanticsLabel: '点赞',
|
semanticsLabel: '点赞',
|
||||||
animation: tripleAnimation,
|
animation: introController.tripleAnimation,
|
||||||
onStartTriple: () {
|
onStartTriple: () {
|
||||||
plPlayerController.tripling = true;
|
plPlayerController.tripling = true;
|
||||||
onStartTriple();
|
introController.onStartTriple();
|
||||||
},
|
},
|
||||||
onCancelTriple: ([bool isTap = false]) {
|
onCancelTriple: ([bool isTapUp = false]) {
|
||||||
plPlayerController
|
plPlayerController
|
||||||
..tripling = false
|
..tripling = false
|
||||||
..hideTaskControls();
|
..hideTaskControls();
|
||||||
onCancelTriple(isTap);
|
introController.onCancelTriple(isTapUp);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -2329,7 +2327,7 @@ class HeaderControlState extends TripleState<HeaderControl> {
|
|||||||
child: Obx(
|
child: Obx(
|
||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
expand: false,
|
expand: false,
|
||||||
animation: tripleAnimation,
|
animation: introController.tripleAnimation,
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
FontAwesomeIcons.b,
|
FontAwesomeIcons.b,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
@@ -2347,7 +2345,7 @@ class HeaderControlState extends TripleState<HeaderControl> {
|
|||||||
child: Obx(
|
child: Obx(
|
||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
expand: false,
|
expand: false,
|
||||||
animation: tripleAnimation,
|
animation: introController.tripleAnimation,
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
FontAwesomeIcons.star,
|
FontAwesomeIcons.star,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
|||||||
@@ -55,8 +55,81 @@ class PlayerFocus extends StatelessWidget {
|
|||||||
bool get isFullScreen => plPlayerController.isFullScreen.value;
|
bool get isFullScreen => plPlayerController.isFullScreen.value;
|
||||||
bool get hasPlayer => plPlayerController.videoPlayerController != null;
|
bool get hasPlayer => plPlayerController.videoPlayerController != null;
|
||||||
|
|
||||||
|
void _setVolume({required bool isIncrease}) {
|
||||||
|
final volume = isIncrease
|
||||||
|
? math.min(1.0, plPlayerController.volume.value + 0.1)
|
||||||
|
: math.max(0.0, plPlayerController.volume.value - 0.1);
|
||||||
|
plPlayerController.setVolume(volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _updateVolume(KeyEvent event, {required bool isIncrease}) {
|
||||||
|
if (event is KeyDownEvent) {
|
||||||
|
if (hasPlayer) {
|
||||||
|
plPlayerController
|
||||||
|
..cancelLongPressTimer()
|
||||||
|
..longPressTimer ??= Timer.periodic(
|
||||||
|
const Duration(milliseconds: 200),
|
||||||
|
(_) => _setVolume(isIncrease: isIncrease),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if (event is KeyUpEvent) {
|
||||||
|
if (plPlayerController.longPressTimer?.tick == 0 && hasPlayer) {
|
||||||
|
_setVolume(isIncrease: isIncrease);
|
||||||
|
}
|
||||||
|
plPlayerController.cancelLongPressTimer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool _handleKey(KeyEvent event) {
|
bool _handleKey(KeyEvent event) {
|
||||||
final key = event.logicalKey;
|
final key = event.logicalKey;
|
||||||
|
|
||||||
|
final isKeyQ = key == LogicalKeyboardKey.keyQ;
|
||||||
|
if (isKeyQ || key == LogicalKeyboardKey.keyR) {
|
||||||
|
if (!plPlayerController.isLive) {
|
||||||
|
if (event is KeyDownEvent) {
|
||||||
|
introController!.onStartTriple();
|
||||||
|
} else if (event is KeyUpEvent) {
|
||||||
|
introController!.onCancelTriple(isKeyQ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final isArrowUp = key == LogicalKeyboardKey.arrowUp;
|
||||||
|
if (isArrowUp || key == LogicalKeyboardKey.arrowDown) {
|
||||||
|
_updateVolume(event, isIncrease: isArrowUp);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key == LogicalKeyboardKey.arrowRight) {
|
||||||
|
if (!plPlayerController.isLive) {
|
||||||
|
if (event is KeyDownEvent) {
|
||||||
|
if (hasPlayer && !plPlayerController.longPressStatus.value) {
|
||||||
|
plPlayerController
|
||||||
|
..cancelLongPressTimer()
|
||||||
|
..longPressTimer ??= Timer(
|
||||||
|
const Duration(milliseconds: 200),
|
||||||
|
() => plPlayerController
|
||||||
|
..cancelLongPressTimer()
|
||||||
|
..setLongPressStatus(true),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if (event is KeyUpEvent) {
|
||||||
|
plPlayerController.cancelLongPressTimer();
|
||||||
|
if (hasPlayer) {
|
||||||
|
if (plPlayerController.longPressStatus.value) {
|
||||||
|
plPlayerController.setLongPressStatus(false);
|
||||||
|
} else {
|
||||||
|
plPlayerController.onForward(
|
||||||
|
plPlayerController.fastForBackwardDuration,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (event is KeyDownEvent) {
|
if (event is KeyDownEvent) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case LogicalKeyboardKey.space:
|
case LogicalKeyboardKey.space:
|
||||||
@@ -101,20 +174,6 @@ class PlayerFocus extends StatelessWidget {
|
|||||||
plPlayerController.toggleDesktopPip();
|
plPlayerController.toggleDesktopPip();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case LogicalKeyboardKey.arrowUp:
|
|
||||||
if (hasPlayer) {
|
|
||||||
final volume = math.min(1.0, plPlayerController.volume.value + 0.1);
|
|
||||||
plPlayerController.setVolume(volume);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case LogicalKeyboardKey.arrowDown:
|
|
||||||
if (hasPlayer) {
|
|
||||||
final volume = math.max(0.0, plPlayerController.volume.value - 0.1);
|
|
||||||
plPlayerController.setVolume(volume);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case LogicalKeyboardKey.keyM:
|
case LogicalKeyboardKey.keyM:
|
||||||
if (hasPlayer) {
|
if (hasPlayer) {
|
||||||
final isMuted = !plPlayerController.isMuted;
|
final isMuted = !plPlayerController.isMuted;
|
||||||
@@ -141,10 +200,6 @@ class PlayerFocus extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case LogicalKeyboardKey.keyQ:
|
|
||||||
introController?.actionLikeVideo();
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case LogicalKeyboardKey.keyW:
|
case LogicalKeyboardKey.keyW:
|
||||||
introController?.actionCoinVideo();
|
introController?.actionCoinVideo();
|
||||||
return true;
|
return true;
|
||||||
@@ -153,7 +208,7 @@ class PlayerFocus extends StatelessWidget {
|
|||||||
introController?.actionFavVideo(isQuick: true);
|
introController?.actionFavVideo(isQuick: true);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case LogicalKeyboardKey.keyR:
|
case LogicalKeyboardKey.keyT || LogicalKeyboardKey.keyV:
|
||||||
introController?.viewLater();
|
introController?.viewLater();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -182,29 +237,6 @@ class PlayerFocus extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == LogicalKeyboardKey.arrowRight) {
|
|
||||||
if (!plPlayerController.isLive && hasPlayer) {
|
|
||||||
if (event is KeyDownEvent) {
|
|
||||||
if (!plPlayerController.longPressStatus.value) {
|
|
||||||
plPlayerController.longPressTimer ??= Timer(
|
|
||||||
const Duration(milliseconds: 200),
|
|
||||||
() => plPlayerController.setLongPressStatus(true),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else if (event is KeyUpEvent) {
|
|
||||||
plPlayerController.cancelLongPressTimer();
|
|
||||||
if (plPlayerController.longPressStatus.value) {
|
|
||||||
plPlayerController.setLongPressStatus(false);
|
|
||||||
} else {
|
|
||||||
plPlayerController.onForward(
|
|
||||||
plPlayerController.fastForBackwardDuration,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ class PlPlayerController {
|
|||||||
final width = state.width ?? this.width ?? 16;
|
final width = state.width ?? this.width ?? 16;
|
||||||
final height = state.height ?? this.height ?? 9;
|
final height = state.height ?? this.height ?? 9;
|
||||||
if (height > width) {
|
if (height > width) {
|
||||||
size = Size(400.0, 400.0 * height / width);
|
size = Size(280.0, 280.0 * height / width);
|
||||||
} else {
|
} else {
|
||||||
size = Size(280.0 * width / height, 280.0);
|
size = Size(280.0 * width / height, 280.0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,7 @@ class AudioSessionHandler {
|
|||||||
|
|
||||||
Future<void> initSession() async {
|
Future<void> initSession() async {
|
||||||
session = await AudioSession.instance;
|
session = await AudioSession.instance;
|
||||||
session.configure(
|
session.configure(const AudioSessionConfiguration.music());
|
||||||
const AudioSessionConfiguration.music().copyWith(
|
|
||||||
avAudioSessionSetActiveOptions:
|
|
||||||
AVAudioSessionSetActiveOptions.notifyOthersOnDeactivation,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
session.interruptionEventStream.listen((event) {
|
session.interruptionEventStream.listen((event) {
|
||||||
final playerStatus = PlPlayerController.getPlayerStatusIfExists();
|
final playerStatus = PlPlayerController.getPlayerStatusIfExists();
|
||||||
|
|||||||
Reference in New Issue
Block a user