Question

I am playing a video in a MediaElement in a WPF application. However when I am programatically invoking the Play() , Pause() or Stop() I get an error message saying:

Cannot control media unless LoadedBehavior or UnloadedBehavior is set to Manual.

I have no idea about it.

Can someone tell me how can these be set to MANUAL?

Was it helpful?

Solution

In XAML you can set the value to the properties like this:

<MediaElement x:Name="player"
              LoadedBehavior="Manual"
              UnloadedBehavior="Stop" ... />                  

Or using code behind:

player.LoadedBehavior = MediaState.Manual;
player.UnloadedBehavior = MediaState.Stop;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top