sergey.sitnikov.nt
Topic Author
Posts: 4
Joined: 16 Oct 2020, 13:58

Controlling MediaElement from XAML with MediaTimeline

12 May 2021, 13:34

Hi guys,

I am unable to find the way to control MediaElement playback from XAML with the Storyboard and MediaTimeline as it is not yet implemented. Is there any workaround for it at the moment?

Cheers,
Sergey
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Controlling MediaElement from XAML with MediaTimeline

12 May 2021, 14:11

Hi Sergey, we provide interactivity actions (PlayMediaAction, PauseMediaAction, RewindMediaAction and StopMediaAction) that can be executed with triggers, for example when a property changes or a storyboard completes.

Is that something you can use?
 
sergey.sitnikov.nt
Topic Author
Posts: 4
Joined: 16 Oct 2020, 13:58

Re: Controlling MediaElement from XAML with MediaTimeline

12 May 2021, 14:31

Yes, thank you Sergio! I have found those in the code:
<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
  xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
  xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions">
      <MediaElement Source="video.mp4" LoadedBehavior="Manual">
          <i:Interaction.Triggers>
              <i:EventTrigger EventName="MouseDown">
                  <noesis:PlayMediaAction />
              </i:EventTrigger>
         </i:Interaction.Triggers>
    </MediaElement>
</Grid>
Are there any plans to implement MediaTimeline in the future to keep it consistent with the WPF functionality?

Cheers,
Sergey
 
sergey.sitnikov.nt
Topic Author
Posts: 4
Joined: 16 Oct 2020, 13:58

Re: Controlling MediaElement from XAML with MediaTimeline

12 May 2021, 16:45

Hi Sergio,

I have tried to use those actions, however there are two issues related to it:

1) The latest publicly available Noesis.GUI.Extensions library (from NuGet) is 3.0.5 and it doesn't have those actions implemented. That makes Blend to trigger an error.
2) In UE4 when I use those actions to repeat the playback the video texture is not updated (staying black) but the sound is working correctly (repeating).
<i:EventTrigger EventName="MediaEnded">
<noesis:StopMediaAction/>
<noesis:RewindMediaAction/>
<noesis:PlayMediaAction/>
</i:EventTrigger>
I have also tired a bit different approach with a custom MediaElement component and used Stop, SetPosition and Play on MediaEnded. Still the same issue with black texture.

Have you got any suggestions?

Cheers,
Sergey

P.S. I managed to work around that issue using Close() instead of Stop() before playing the file again. That actually destroyed and created a new instance of the MediaPlayer and fixed the problem. However, it would be great to know if there is a better approach to it and whether it is necessary to do something else to make those Actions work the same way (it wouldn't work out of the box for there is no Close action yet).

Sergey
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Controlling MediaElement from XAML with MediaTimeline

13 May 2021, 10:35

I updated the Noesis.GUI.Extensions nuget package and now it includes those media actions to be used in Blend.

Regarding the loop issue, I created ticket #2019 because we should fix that. In the meantime, as you found, you can workaround it by closing the media element and starting it again.

Who is online

Users browsing this forum: No registered users and 68 guests