Open seafraf opened 2 years ago
<MainWindow>
<ffme:MediaElement x:Name="videoPlayer" LoadedBehavior="Play" UnloadedBehavior="Manual" Loaded="OnLoaded" />
<Button Click="OnButton" />
`</MainWindow>`
private async void OnLoaded(object _, RoutedEventArgs _)
{
// video loads fine
await videoPlayer.Open("a.mp4")
}
private async void OnButton(object _, RoutedEventArgs _)
{
// Try it's
await videoPlayer.Close();
// video loads preview but then crashes in a second or less
await videoPlayer.Open("b.mp4");
}
If the source of the media has not changed, you can try this method 'await videoPlayer.Play()'
// Add in OnLoaded or Init fuction,check out panel in IDE MediaElement.FFmpegMessageLogged += (s, e) => { if (e.MessageType != MediaLogMessageType.Warning && e.MessageType != MediaLogMessageType.Error) return; if (string.IsNullOrWhiteSpace(e.Message) == false && e.Message.ContainsOrdinal("Using non-standard frame rate")) return; Debug.WriteLine(e); };
Calling MediaElement.Open from an OnLoaded event causes AccessViolation
This is not an urgent issue, hoping by reporting this that it helps discover underlying issues for other people's problems.
I have an application where I have a list of videos to choose from and the first one from the list would have been loaded when the application starts with a call to MediaElement.Open, subsequent calls to MediaElement.Open would cause the application to crash wiht an AccessViolation (native memory issue, ffmpeg related).
In my tests:
Is this issue related to why the Source property is no longer favored?
Issue Categories
Version Information
Steps to Reproduce
Expected Results
Sample Code
XAML
C