Esempio n. 1
0
        /// <summary>
        /// Called when an underlying media engine property is changed.
        /// This is used to handle property change notifications
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="propertyName">Name of the property.</param>
        public void OnPropertyChanged(object sender, string propertyName)
        {
            // TODO: bug sometimes continuously resizing the window causes everything to freeze.
            // This might be because of excessive property change notifications. It might be a good idea
            // to notify everything at once every say, 25ms.
            // Either that or attach to the properties from the mediaelement via WPF binding.
            WindowsPlatform.Instance.Gui?.Invoke(DispatcherPriority.DataBind, () =>
            {
                switch (propertyName)
                {
                // forward internal changes to the MediaElement dependency Properties
                case nameof(MediaEngine.Source):
                    Control.Source = Control.MediaCore.Source;
                    break;

                case nameof(MediaEngine.LoadedBehavior):
                    Control.LoadedBehavior = (System.Windows.Controls.MediaState)Control.MediaCore.LoadedBehavior;
                    break;

                case nameof(MediaEngine.SpeedRatio):
                    Control.SpeedRatio = Control.MediaCore.SpeedRatio;
                    break;

                case nameof(MediaEngine.UnloadedBehavior):
                    Control.UnloadedBehavior = (System.Windows.Controls.MediaState)Control.MediaCore.UnloadedBehavior;
                    break;

                case nameof(MediaEngine.Volume):
                    Control.Volume = Control.MediaCore.Volume;
                    break;

                case nameof(MediaEngine.Balance):
                    Control.Balance = Control.MediaCore.Balance;
                    break;

                case nameof(MediaEngine.IsMuted):
                    Control.IsMuted = Control.MediaCore.IsMuted;
                    break;

                case nameof(MediaEngine.ScrubbingEnabled):
                    Control.ScrubbingEnabled = Control.MediaCore.ScrubbingEnabled;
                    break;

                case nameof(MediaEngine.Position):
                    Control.Position = Control.MediaCore.Position;
                    break;

                default:
                    // Simply forward notification of same-named properties
                    Control?.RaisePropertyChangedEvent(propertyName);
                    break;
                }
            });
        }
        /// <summary>
        /// Called when an underlying media engine property is changed.
        /// This is used to handle property change notifications
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="propertyName">Name of the property.</param>
        public void OnPropertyChanged(object sender, string propertyName)
        {
            WindowsPlatform.Instance.Gui?.Invoke(DispatcherPriority.DataBind, () =>
            {
                switch (propertyName)
                {
                // forward internal changes to the MediaElement dependency Properties
                case nameof(MediaEngine.Source):
                    Control.Source = Control.MediaCore.Source;
                    break;

                case nameof(MediaEngine.LoadedBehavior):
                    Control.LoadedBehavior = (System.Windows.Controls.MediaState)Control.MediaCore.LoadedBehavior;
                    break;

                case nameof(MediaEngine.SpeedRatio):
                    Control.SpeedRatio = Control.MediaCore.SpeedRatio;
                    break;

                case nameof(MediaEngine.UnloadedBehavior):
                    Control.UnloadedBehavior = (System.Windows.Controls.MediaState)Control.MediaCore.UnloadedBehavior;
                    break;

                case nameof(MediaEngine.Volume):
                    Control.Volume = Control.MediaCore.Volume;
                    break;

                case nameof(MediaEngine.Balance):
                    Control.Balance = Control.MediaCore.Balance;
                    break;

                case nameof(MediaEngine.IsMuted):
                    Control.IsMuted = Control.MediaCore.IsMuted;
                    break;

                case nameof(MediaEngine.ScrubbingEnabled):
                    Control.ScrubbingEnabled = Control.MediaCore.ScrubbingEnabled;
                    break;

                case nameof(MediaEngine.Position):
                    Control.Position = Control.MediaCore.Position;
                    break;

                default:
                    // Simply forward notification of same-named properties
                    Control?.RaisePropertyChangedEvent(propertyName);
                    break;
                }
            });
        }