-1

When LoadedBehavior attribute of MediaElement, is set to "Manual", I can see the video in the previewer, but when I run the application, the video is not displayed at all.

When LoadedBehavior is set to "Play", it works fine.

The 'Build Action' property of the video file is set to "Content". The 'Copy to output' property of the video file is set to "Copy Always".

This is the code which doesn't display the Video:

   <MediaElement Source="Videos\abc.mp4" Height="300" Width="300" LoadedBehavior="Manual"/>
S Itzik
  • 494
  • 3
  • 12

2 Answers2

0

You have set the LoadedBehavior to "Manual" this means you need to start the MediaElement 'manual' (ha funny ;) ) Just call Play() in your code

Here is the doc

Niklas
  • 172
  • 2
  • 8
  • It is written: "LoadedBehavior must be set to Manual in order to interactively control media with the Play, Pause, and Stop methods." 'Interactively' means (I guess) the USER will be able to play, pause, stop... So I expect the media player to be displayed with the right buttons, and let the user to chose when to play, pause, stop.. – S Itzik Jun 05 '20 at 09:37
  • You have to add the buttons by your self – Niklas Jun 05 '20 at 11:02
0

So I expect the media player to be displayed with the right buttons, and let the user to chose when to play, pause, stop

Then your expectations are simply plain wrong because the MediaElement control doesn't come with any such buttons.

You'll need to add the buttons yourself and then hook up event handlers or commands to them where you call the Play, Pause and Stop methods.

The other option is to call the method(s) programmatically without the use of any buttons in the UI, but when you set the LoadedBehavior to Manual, you have to call Play() explicitly one way or the other for the media to play.

mm8
  • 163,881
  • 10
  • 57
  • 88