Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Audio slider: how to detect when user changes its position through ViewModel?

$
0
0

I've been trying to create an audio player which uses a slider to control its time. Thus, when user changes the slider position, the player seeks for that position on audio. In my case, I use ViewModel, so I'd like to do all control through ViewModel and not on View (codebehind).

I also use XAML, and my slider is it:

<Slider x:Name="sliderAudio"
        Minimum="0" Maximum="{Binding Duration}"
        Value="{Binding AudioCurrentProgress}" />

As you can see, there are two binding values: Duration, which is the duration time of the audio, and AudioCurrentProgress, which returns me the current position of the audio that is playing (or not).

Thus, I use AudioCurrentProgress for two things: 1) control the slider position and 2) play the audio exactly where the user wants.
That I already can do it! But only in a situation: if user stops the player and touch "play" again.

What I'd want to do is:
How can I detect when user changes the slider position when player IS PLAYING?

The problem is: AudioCurrentProgress changes its value everytime when player is playing.
So, I don't know it slider changes the position if user moved it or it it changes because player is playing. You know what I meant?


Viewing all articles
Browse latest Browse all 91519

Trending Articles