unosquare / ffmediaelement

FFME: The Advanced WPF MediaElement (based on FFmpeg)
https://unosquare.github.io/ffmediaelement/
Other
1.15k stars 238 forks source link

Error in binding SpeedRatio & Volume #627

Closed TMS-Namespace closed 1 month ago

TMS-Namespace commented 1 year ago

Issue Title (Error in binding SpeedRatio & Volume)

Although binding other properties works fine, and those two seems to be dependency properties, and they do work if set programmatically, WPF binding and the designer throws an exception (Object reference not set to an instance of an object, see below), and during run time (compiles with no issues), no value changes takes place (in either directions).

Issue Categories

Version Information

Sample Code

XAML

image

Stack trace from the WPF designer

at Unosquare.FFME.MediaElement.OnSpeedRatioPropertyChanging(DependencyObject d, Object value) at System.Windows.DependencyObject.ProcessCoerceValue(DependencyProperty dp, PropertyMetadata metadata, EntryIndex& entryIndex, Int32& targetIndex, EffectiveValueEntry& newEntry, EffectiveValueEntry& oldEntry, Object& oldValue, Object baseValue, Object controlValue, CoerceValueCallback coerceValueCallback, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, Boolean skipBaseValueChecks) at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue) at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp) at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange) at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange) at System.Windows.Data.BindingExpression.Activate(Object item) at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt) at System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance) at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance) at MS.Internal.Data.DataBindEngine.Run(Object arg) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

kuangxj commented 1 year ago

It's work for me,do it.

<ffme:MediaElement
                x:Name="player"

                Panel.ZIndex="0"
                IsDesignPreviewEnabled="True"
                LoadedBehavior="Play"
                Stretch="Fill"
                UnloadedBehavior="Manual"
                Volume="{Binding ElementName=sliderVolume, Path=Value, Mode=TwoWay}" />
<Slider
                                x:Name="sliderVolume"
                                Width="100"
                                Maximum="1"                    
                                TickFrequency=".01"
                                Value="1" />