private void OnMediaFileChanged(object sender, MediaFileChangedEventArgs e) { if (CurrentMediaFile?.Url == e?.File?.Url) { MediaNotificationManager?.UpdateNotifications(e?.File, Status); } MediaFileChanged?.Invoke(sender, e); }
private void OnStatusChanged(object sender, StatusChangedEventArgs e) { if (sender != CurrentPlaybackManager) { return; } MediaNotificationManager?.UpdateNotifications(MediaQueue.Current, e.Status); StatusChanged?.Invoke(sender, e); }
/// <summary> /// Adds all MediaFiles to the Queue and starts playing the first item /// </summary> /// <param name="mediaFiles"></param> /// <returns></returns> public async Task Play(IEnumerable <IMediaFile> mediaFiles) { MediaQueue.Clear(); MediaQueue.AddRange(mediaFiles); await PlayNext(); MediaNotificationManager?.StartNotification(CurrentMediaFile); }
public async Task Seek(TimeSpan position) { if (CurrentPlaybackManager == null) { return; } await CurrentPlaybackManager.Seek(position); MediaNotificationManager?.UpdateNotifications(CurrentMediaFile, Status); }
public async Task Stop() { if (CurrentPlaybackManager == null) { return; } await CurrentPlaybackManager.Stop(); MediaNotificationManager?.StopNotifications(); }
/// <summary> /// Adds all MediaFiles to the Queue and starts playing the first item /// </summary> /// <param name="mediaFiles"></param> /// <returns></returns> public async Task Play(IEnumerable <IMediaFile> mediaFiles) { MediaQueue.Clear(); MediaQueue.AddRange(mediaFiles); // Play from index 0 MediaQueue.SetIndexAsCurrent(0); await PlayCurrent(); MediaNotificationManager?.StartNotification(CurrentMediaFile); }
/// <summary> /// Adds all MediaFiles to the Queue and starts playing the first item /// </summary> /// <param name="mediaFiles"></param> /// <returns></returns> public async Task Play(IEnumerable <IMediaFile> mediaFiles) { var enumerable = mediaFiles as IList <IMediaFile> ?? mediaFiles.ToList(); MediaQueue.Clear(); MediaQueue.AddRange(enumerable); await Task.WhenAll( PlayNext(), GetMediaInformation(enumerable), Task.Run(() => MediaNotificationManager?.StartNotification(MediaQueue.Current))); }
private void OnPlayingChanged(object sender, PlayingChangedEventArgs e) { if (sender == CurrentPlaybackManager) { if (!_startedPlaying && Duration != TimeSpan.Zero) { MediaNotificationManager?.UpdateNotifications(MediaQueue.Current, Status); _startedPlaying = true; } PlayingChanged?.Invoke(sender, e); } }
private void OnStatusChanged(object sender, StatusChangedEventArgs e) { if (sender != CurrentPlaybackManager) { return; } if (Status == MediaPlayerStatus.Playing) { _startedPlaying = false; } MediaNotificationManager?.UpdateNotifications(CurrentMediaFile, e.Status); StatusChanged?.Invoke(sender, e); }
public async Task Play(IMediaFile mediaFile = null) { if (mediaFile == null) { if (Status == MediaPlayerStatus.Paused) { await Resume(); return; } mediaFile = CurrentMediaFile; } if (_currentPlaybackManager != null && Status == MediaPlayerStatus.Failed) { await PlayNext(); return; } if (mediaFile == null) { await Play(MediaQueue); return; } if (!MediaQueue.Contains(mediaFile)) { MediaQueue.Add(mediaFile); } MediaQueue.SetTrackAsCurrent(mediaFile); await RaiseMediaFileFailedEventOnException(async() => { await PlayCurrent(); }); MediaNotificationManager?.StartNotification(mediaFile); }
/// <summary> /// Adds MediaFile to the Queue and starts playing /// </summary> /// <param name="mediaFile"></param> /// <returns></returns> public async Task Play(IMediaFile mediaFile) { if (_currentPlaybackManager != null && Status == MediaPlayerStatus.Failed) { await PlayNext(); return; } if (mediaFile == null) { await Play(MediaQueue); return; } if (!MediaQueue.Contains(mediaFile)) { MediaQueue.Add(mediaFile); } MediaQueue.SetTrackAsCurrent(mediaFile); try { var beforePlayTask = _onBeforePlay?.Invoke(_currentMediaFile); if (beforePlayTask != null) { await beforePlayTask; } await CurrentPlaybackManager.Play(mediaFile); await GetMediaInformation(new[] { mediaFile }); MediaNotificationManager?.StartNotification(mediaFile); } catch (Exception ex) { OnMediaFileFailed(this, new MediaFileFailedEventArgs(ex, mediaFile)); } }
public async Task Stop() { await CurrentPlaybackManager.Stop(); MediaNotificationManager?.StopNotifications(); }