async void Play() { if (_paused && _player != null) { _paused = false; //We are simply paused so just start again _player.Start(); StartForeground(); return; } if (_player == null) { IntializePlayer(); } if (_player.IsPlaying) { return; } try { if (CurrentEpisode == null || Math.Abs(CurrentEpisode.Duration - CurrentEpisode.CurrentTime) < COMPARISON_EPSILON || !AudioDownloader.HasLocalFile(CurrentEpisode.RemoteUrl, CurrentEpisode.FileSize)) { return; } var file = new Java.IO.File(AudioDownloader.GetFilePath(CurrentEpisode.RemoteUrl)); var fis = new Java.IO.FileInputStream(file); // TODO reorganize it to play selected audio. // await player.SetDataSourceAsync(ApplicationContext, Net.Uri.Parse(Mp3 await _player.SetDataSourceAsync(fis.FD); var focusResult = _audioManager.RequestAudioFocus(this, Stream.Music, AudioFocus.Gain); if (focusResult != AudioFocusRequest.Granted) { Log.Debug(DEBUG_TAG, "Could not get audio focus"); } _player.Prepare(); CurrentPosition = (int)CurrentEpisode.CurrentTime; AquireWifiLock(); StartForeground(); } catch (Exception ex) { Log.Debug(DEBUG_TAG, "Unable to start playback: " + ex); } }