You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Delaying the load of the first video by any amount of time fixes this, making the user click the first video themselves fixes my problem, also adding an arbitrary delay to the Loaded event fixes this issue (tested with Task.Delay with a value as low as 1ms)
Closing the video seems to work, so I don't think it's to do with any attempts to free memory when changing videos
Launching the sample application with a path to the video does not cause a crash when changing videos, I am assuming this is because of how the sample application loads videos using DelegateCommand's
Is this issue related to why the Source property is no longer favored?
privateasyncvoidOnLoaded(object_,RoutedEventArgs_){// video loads fineawait videoPlayer.Open("a.mp4")}privateasyncvoidOnButton(object_,RoutedEventArgs_){// video loads preview but then crashes in a second or lessawait videoPlayer.Open("b.mp4")}
The text was updated successfully, but these errors were encountered:
seafraf
changed the title
Calling MediaElement.Open from an OnLoaded event causes
Calling MediaElement.Open from an OnLoaded event causes AccessViolation
Apr 29, 2022
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#
The text was updated successfully, but these errors were encountered: