/// <inheritdoc /> public void OnMediaOpened(MediaEngine sender, MediaInfo mediaInfo) { if (Parent == null || sender == null) { return; } Library.GuiContext.EnqueueInvoke(async() => { // Set initial controller properties // Has to be on the GUI thread as we are reading dependency properties sender.State.Balance = Parent.Balance; sender.State.Volume = Parent.Volume; sender.State.IsMuted = Parent.IsMuted; sender.State.VerticalSyncEnabled = Parent.VerticalSyncEnabled; sender.State.ScrubbingEnabled = Parent.ScrubbingEnabled; // Notify the end user media has opened successfully Parent.PostMediaOpenedEvent(mediaInfo); try { // Start playback if we don't support pausing if (sender.State.CanPause == false) { await sender.Play(); return; } if (Parent.LoadedBehavior == MediaPlaybackState.Play) { await sender.Play(); } else if (Parent.LoadedBehavior == MediaPlaybackState.Pause) { await sender.Pause(); } } finally { Parent.PostMediaReadyEvent(); } }); }
/// <inheritdoc /> public void OnMediaOpened(MediaEngine sender, MediaInfo mediaInfo) { if (Parent == null || sender == null) { return; } GuiContext.Current.EnqueueInvoke(async() => { // Set initial controller properties // Has to be on the GUI thread as we are reading dependency properties sender.State.Volume = Parent.Volume; sender.State.IsMuted = Parent.IsMuted; sender.State.Balance = Parent.Balance; // Notify the end user media has opened successfully Parent.PostMediaOpenedEvent(mediaInfo); // Start playback if we don't support pausing if (sender.State.CanPause == false) { await sender.Play(); return; } // ReSharper disable once ConvertIfStatementToSwitchStatement if (Parent.LoadedBehavior == System.Windows.Controls.MediaState.Play) { await sender.Play(); } else if (Parent.LoadedBehavior == System.Windows.Controls.MediaState.Pause) { await sender.Pause(); } Parent.PostMediaReadyEvent(); }); }