Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to watch a MediaPlayer and get feedback on it's CurrentProgress?
    primarykey
    data
    text
    <p>I'm writing an android app that uses the <code>MediaPlayer</code>. I've created a custom <code>IAudioPlayer</code> as a wrapper for the MediaPlayer so that I can eventually extend it to iOS.</p> <pre><code>public interface IAudioPlayer { bool IsPlaying { get; } void Play(string fileName, int startingPoint); void Play(string fileName); void Pause(); void Stop(); int CurrentPosition(); bool HasFile(); void SkipForward(int seconds); void SkipBackward(int seconds); void SeekTo(int seconds); } </code></pre> <p>Our app is structured using the Mvvm pattern and is using MvvmCross.</p> <p>On our FragmentViewModel we've got commands such as <code>IPlayCommand</code>, <code>IStopCommand</code>, etc.</p> <pre><code>public class HomeFragmentViewModel : ViewModelBase { public HomeFragmentViewModel(IPlayCommand playCommand, IStopCommand stopCommand, ISkipForwardCommand skipForwardCommand, ISkipBackwardCommand skipBackwardCommand) { _playCommand = playCommand; _stopCommand = stopCommand; _skipForwardCommand = skipForwardCommand; _skipBackwardCommand = skipBackwardCommand; } private string _playPauseIcon = FontAwesome.icon_play; public string PlayPauseIcon { get { return _playPauseIcon; } set { _playPauseIcon = value; RaisePropertyChanged(() =&gt; PlayPauseIcon); } } private IPlayCommand _playCommand; public IPlayCommand PlayCommand { get { return _playCommand; } set { _playCommand = value; RaisePropertyChanged(() =&gt; PlayCommand); } } private IStopCommand _stopCommand; public IStopCommand StopCommand { get { return _stopCommand; } set { _stopCommand = value; RaisePropertyChanged(() =&gt; StopCommand); } } private ISkipForwardCommand _skipForwardCommand; public ISkipForwardCommand SkipForwardCommand { get { return _skipForwardCommand; } set { _skipForwardCommand = value; RaisePropertyChanged(() =&gt; SkipForwardCommand); } } private ISkipBackwardCommand _skipBackwardCommand; public ISkipBackwardCommand SkipBackwardCommand { get { return _skipBackwardCommand; } set { _skipBackwardCommand = value; RaisePropertyChanged(() =&gt; SkipBackwardCommand); } } } </code></pre> <p>On our View we've got buttons that bind to those commands, and all is working as expected.</p> <p><strong>However</strong></p> <p>Our view also has a <code>SeekBar</code> that we're going to use for quick scrubbing by the user. The seekbar needs to do two things...</p> <ol> <li>allow the user quickly navigate to the spot that's required (this one "should" be easy</li> <li>automatically update based on the track's current progress (this one I'm stuck on)</li> </ol> <p>How can I write a notifier that triggers every second, and automatically update the seekbar binding? This notifier would need to live in the PCL with the Command Objects so that it can work cross platform. I'm struggling with getting started on this... I'm not sure where to create it or how to wire it up.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload