unosquare / ffmediaelement

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

Stretch is ignored when used as VisualBrush #405

Closed FroggieFrog closed 5 years ago

FroggieFrog commented 5 years ago

Stretch is ignored when used as VisualBrush

When using the control Unosquare.FFME.MediaElement as a VisualBrush then the Stretch property is not working. If the control is used directly then evrything is working as expected.

What I'm trying to achieve is to play the video on 2 different controls on different monitors. So the idea was to use a VisualBrush and use it on both controls. Maybe there is a better way I don't know of.

Issue Categories

Version Information

Steps to Reproduce

  1. Create a VisualBrush as Resource
  2. Use Unosquare.FFME.MediaElemen as the Visual
  3. Set Stretch to Uniform

Expected Results

The Stretch property is respected.

Sample Code

XAML

<MainWindow>
<MainWindow.Resources>
        <VisualBrush x:Key="brushMedia">
            <VisualBrush.Visual>
                <ffme:MediaElement x:Name="mediaPlayer"
                                   Source="{Binding FilePath}"
                                   Background="Black"
                                   Stretch="Uniform"
                                   LoadedBehavior="Manual"
                                   UnloadedBehavior="Close"
                                   ScrubbingEnabled="True"
                                   MediaOpened="MediaPlayer_MediaOpened"
                                   MediaEnded="MediaPlayer_MediaEnded" />
            </VisualBrush.Visual>
        </VisualBrush>
    </MainWindow.Resources>
    <Grid>
        <Rectangle Fill="{StaticResource brushMedia}" />
</MainWindow>
mariodivece commented 5 years ago

Please see related question #121

FroggieFrog commented 5 years ago

Thank you for your hint at #121 (I didn't find it). But the original issue (when using in a VisaulBrush is still present. So I propose to reopen it.

mariodivece commented 5 years ago

Check out https://github.com/unosquare/ffmediaelement/issues/121#issuecomment-358993066 You need to copy the image data to a WritableBitmap and use that WriteableBitmap as the visual brush. Does that not work?

FroggieFrog commented 5 years ago

Yeah, that works. But I would still consider it a workaround. But nevertheless: Thank you for your help! And even more thanks for your work! 🎉