92 lines
2.4 KiB
Dart
92 lines
2.4 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:aslan/chatvibe_ui/components/text/at_text.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:aslan/chatvibe_core/utilities/at_date_utils.dart';
|
|
import 'package:aslan/chatvibe_managers/audio_manager.dart';
|
|
import 'package:aslan/chatvibe_managers/rtc_manager.dart';
|
|
|
|
class ATMusicSeekBar extends StatefulWidget {
|
|
const ATMusicSeekBar({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
_ATMusicSeekBarState createState() => _ATMusicSeekBarState();
|
|
}
|
|
|
|
class _ATMusicSeekBarState extends State<ATMusicSeekBar> {
|
|
int _currentValue = 0;
|
|
int _maxValue = 0;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
Provider.of<AudioManager>(
|
|
context!,
|
|
listen: false,
|
|
).changeCall = audioMixingChangeCall;
|
|
}
|
|
|
|
void audioMixingChangeCall(int currentValue, int maxValue){
|
|
if (mounted) {
|
|
setState(() {
|
|
_currentValue = currentValue;
|
|
_maxValue = maxValue;
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
children: [
|
|
SizedBox(
|
|
height: 25.w,
|
|
child: Slider(
|
|
value: _currentValue.toDouble().clamp(0, _maxValue.toDouble()),
|
|
activeColor: Color(0xff9A47FF),
|
|
inactiveColor: Colors.white24,
|
|
min: 0.0,
|
|
max: _maxValue.toDouble(),
|
|
onChanged: (double value) {
|
|
setState(() {
|
|
_currentValue = value.toInt();
|
|
});
|
|
},
|
|
onChangeEnd: (double value) async {
|
|
// 当用户拖动结束时,跳转到指定位置
|
|
await Provider.of<RtcProvider>(
|
|
context,
|
|
listen: false,
|
|
).engine!.setAudioMixingPosition(value.toInt());
|
|
},
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
SizedBox(width: 25.w),
|
|
text(
|
|
ATMDateUtils.millisecondsToMinutesMethod(_currentValue),
|
|
textColor: Colors.white,
|
|
),
|
|
Spacer(),
|
|
text(
|
|
ATMDateUtils.millisecondsToMinutesMethod(_maxValue),
|
|
textColor: Colors.white,
|
|
),
|
|
SizedBox(width: 25.w),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|