72 lines
1.7 KiB
Dart
72 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:aslan/chatvibe_managers/rtc_manager.dart';
|
|
|
|
class ATVolumeSeekBar extends StatefulWidget {
|
|
const ATVolumeSeekBar({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
_ATVolumeSeekBarState createState() => _ATVolumeSeekBarState();
|
|
}
|
|
|
|
class _ATVolumeSeekBarState extends State<ATVolumeSeekBar> {
|
|
int _currentValue = 0;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_getCurrentVolumeAt();
|
|
}
|
|
|
|
void _getCurrentVolumeAt() async {
|
|
// 从声网SDK获取当前播放位置
|
|
int currentPos =
|
|
await Provider.of<RtcProvider>(
|
|
context,
|
|
listen: false,
|
|
).engine!.getAudioMixingPlayoutVolume();
|
|
|
|
if (mounted) {
|
|
setState(() {
|
|
_currentValue = currentPos;
|
|
});
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
children: [
|
|
SizedBox(
|
|
height: 25.w,
|
|
child: Slider(
|
|
value: _currentValue.toDouble().clamp(0, 100.0),
|
|
activeColor: Color(0xff9A47FF),
|
|
inactiveColor: Colors.white24,
|
|
min: 0.0,
|
|
max: 100.0,
|
|
onChanged: (double value) {
|
|
setState(() {
|
|
_currentValue = value.toInt();
|
|
});
|
|
},
|
|
onChangeEnd: (double value) async {
|
|
// 当用户拖动结束时,跳转到指定位置
|
|
await Provider.of<RtcProvider>(
|
|
context,
|
|
listen: false,
|
|
).engine!.adjustAudioMixingVolume(value.toInt());
|
|
},
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|