edited tones, added vibrate
This commit is contained in:
@ -3,11 +3,11 @@ import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_sound/public/flutter_sound_player.dart';
|
||||
import 'package:flutter_sound/flutter_sound.dart';
|
||||
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
||||
import 'package:sendtrain/database/database.dart';
|
||||
import 'package:sendtrain/models/action_model.dart';
|
||||
import 'package:vibration/vibration.dart';
|
||||
|
||||
class ActionTimer with ChangeNotifier {
|
||||
ActionModel? actionModel;
|
||||
@ -56,6 +56,7 @@ class ActionTimer with ChangeNotifier {
|
||||
|
||||
void setup(ActionModel actionModel, ItemScrollController scrollController,
|
||||
[bool resetOnLoad = true]) async {
|
||||
_scrollControllers.clear();
|
||||
_scrollControllers.add(scrollController);
|
||||
|
||||
if (resetOnLoad) {
|
||||
@ -85,7 +86,7 @@ class ActionTimer with ChangeNotifier {
|
||||
Uint8List? countTone;
|
||||
Uint8List? finishTone;
|
||||
await rootBundle
|
||||
.load('assets/audio/count_tone.wav')
|
||||
.load('assets/audio/count_tone.mp3')
|
||||
.then((data) => countTone = data.buffer.asUint8List());
|
||||
await rootBundle
|
||||
.load('assets/audio/count_finish.mp3')
|
||||
@ -102,14 +103,25 @@ class ActionTimer with ChangeNotifier {
|
||||
_currentTime--;
|
||||
|
||||
if (_currentTime <= 3 && _currentTime != 0) {
|
||||
await _mPlayer.startPlayer(
|
||||
fromDataBuffer: countTone, codec: Codec.pcm16WAV);
|
||||
await _mPlayer
|
||||
.startPlayer(fromDataBuffer: countTone, codec: Codec.mp3)
|
||||
.then((duration) async {
|
||||
if (await Vibration.hasVibrator()) {
|
||||
Vibration.vibrate(duration: 250);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (_currentTime == 0) {
|
||||
// move to next action
|
||||
await _mPlayer.startPlayer(
|
||||
fromDataBuffer: finishTone, codec: Codec.mp3);
|
||||
await _mPlayer
|
||||
.startPlayer(fromDataBuffer: finishTone, codec: Codec.mp3)
|
||||
.then((duration) async {
|
||||
if (await Vibration.hasVibrator()) {
|
||||
Vibration.vibrate(duration: 250);
|
||||
}
|
||||
});
|
||||
|
||||
await setAction(state['currentAction'] + 1);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user