Skip to content

Commit

Permalink
fix #489 (allow vibrate while long press)
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuaois committed Jan 13, 2025
1 parent af6f6a4 commit 041e7c6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.VIBRATE"/>
<!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility?hl=en and
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
Expand Down
10 changes: 9 additions & 1 deletion lib/pages/player/player_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:kazumi/pages/video/video_controller.dart';
import 'package:vibration/vibration.dart';
import 'package:window_manager/window_manager.dart';
import 'package:canvas_danmaku/canvas_danmaku.dart';
import 'package:kazumi/bean/dialog/dialog_helper.dart';
Expand Down Expand Up @@ -731,10 +732,17 @@ class _PlayerItemState extends State<PlayerItem>
onDoubleTap: () {
_handleDoubleTap();
},
onLongPressStart: (_) {
onLongPressStart: (_) async {
if (playerController.lockPanel) {
return;
}
if (!Utils.isDesktop()) {
// 检查有无震动权限
if (await Vibration.hasCustomVibrationsSupport() ??
false) {
Vibration.vibrate(duration: 100);
}
}
setState(() {
playerController.showPlaySpeed = true;
});
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ dependencies:
adaptive_theme: ^3.6.0
flutter_displaymode: ^0.6.0

vibration: ^1.8.4
url_launcher: ^6.3.0
device_info_plus: ^10.1.2
window_manager: ^0.4.2
Expand Down

0 comments on commit 041e7c6

Please sign in to comment.