Flutter audio slider with assets_audio_player
I'm trying to create a slider to watch the audio progress and seek some parts of the audio. In order to play local audio files I'm using the assets_audio_player package. This is my code:
Here's an example, position and duration are both Duration() variables
Widget slider() {
return Slider(
value: _position.inSeconds.toDouble(),
min: 0.0,
max: _duration.inSeconds.toDouble(),
onChanged: (double value) {
setState(() {
seekToSecond(value.toInt());
value = value;
});});
}
Related
I want to change the playback speed of the video with the flutter video_player package and save it to the gallery. I changed the playback speed with the property controller.setPlaybackSpeed but I couldn't find how to get the change information of the modified video.
Slider(
value: blur, min: 1, max: 5, onChanged: (value) {
setState(() {
blur = value;
_controller.setPlaybackSpeed(blur);
});
},) ,
I tried to find it with controller.dataSource and controller.value properties but I couldn't find it
I'm using sleek_circular_slider package, but i don't know how to be
the widget as circle, by default it is not
final slider = SleekCircularSlider(
appearance: CircularSliderAppearance(
customWidths: CustomSliderWidths(progressBarWidth: 10)),
min: 10,
max: 28,
initialValue: 14,
);
The package documentation states that the slider object takes an appearance parameter of type CircularSliderAppearance. You can then set angleRange as a parameter on the appearance to get whatever range you require. By default docs state it is 240 degrees.
To get a complete circle, the code would look something like:
final slider = SleekCircularSlider(
appearance: CircularSliderAppearance(angleRange: 360),
onChange: (double value) {
print(value);
});
I want to make music slider like this:
slider image
I am new to dart so please forgive any mistakes in the question.
I am just confused on how to set the time elapsed playing and total time.
my code:
double sliderValue = 0;
Duration max = const Duration(seconds: 120);
Row(
children: [
Text('${sliderValue.toInt()}'),
Slider(
value: sliderValue,
min: 0,
max: max.inSeconds.toDouble(),
onChanged: (double value){
setState(() {
sliderValue = value;
});
}
),
Text('${max.inMinutes}')
],
),
One way is to manually implement it. You can do this by first getting the audio length from the metadata of the file. Once you get that, you can show the current progress based on the total.
Another way is to check out this package. Also, you might be using the audio player package. It also has a callback to get the current position of the audio. Check it here.
I am new to flutter. I am developing a music app. I want to half(180°) or more then half(180°-240°) circular slider which increase or decrease the volume.
Note:
You can use the sleek_circular_slider from pub.dev
Add the dependency to pubspec.yaml
dependencies:
sleek_circular_slider : ^1.1.0
Run flutter packages get to fetch the dependencies.
Import it to your project file
import 'package:sleek_circular_slider/sleek_circular_slider.dart';
Then you can create the slider like so -
final SleekCircularSlider(
min: 0,
max: 100,
initialValue: 0,
onChange: (double value) {
// callback providing a value while its being changed (with a pan gesture)
},
onChangeStart: (double startValue) {
// callback providing a starting value (when a pan gesture starts)
},
onChangeEnd: (double endValue) {
// callback providing an ending value (when a pan gesture ends)
},
innerWidget: (double value) {
//This the widget that will show current value
return Center(child: Text("${value.toInt().toString()} %", style: TextStyle(fontSize: 30.0, fontWeight: FontWeight.w200),));
},
),
This will create something like this -
You can read about more customization options here.
Hi I'm using the flutter video player plugin, I have something similar like this [{phrase:"something", startAt: 1039}, {phrase:"other somthing", startAt: 26500}] is there a way to change in ui the phrase based on the start time while the video is playing.
I have try to use a timer with a duration of 100 ms but I retrieve no exact time from the Flutter video player plugin.
You probably want to take a look at stateful widgets as they allow you to do exactly this. In short, you can set phrase to be some variable and once the video starts you can call setState and change the variable. Flutter will automatically redraw the widget and the text will be updated.
To determine if the video player is playing you can add a listener to your video controller.
_controller = VideoPlayerController.network(
'http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_20mb.mp4',
)
..addListener(() {
final bool isPlaying = _controller.value.isPlaying;
if (isPlaying != _isPlaying) {
setState(() {
_isPlaying = isPlaying;
});
}
})
..initialize().then((_) {
// Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
setState(() {});
});