Memory heap issues when stopping media player
Opened this issue · 0 comments
Ruud-cb commented
C#
//Starting:
StorageFile file = await LocalStorage.GetMediaStorageFile(item);
if (file != null)
{
VlcMediaPlayer.MediaSource = VLC.MediaSource.CreateFromUri(file.Path);
VlcMediaPlayer.Visibility = Visibility.Visible;
}
//Stopping:
if (VlcMediaPlayer != null && VlcMediaPlayer.MediaPlayer != null && VlcMediaPlayer.MediaSource != null && VlcMediaPlayer.MediaPlayer.canPause())
{
VlcMediaPlayer.Pause();
VlcMediaPlayer.Stop();
}
VlcMediaPlayer.Source = null;
VlcMediaPlayer.MediaSource = null;
XAML:
<vlc:MediaElement x:Name="VlcMediaPlayer" Grid.Row="1" Grid.Column="1" AreTransportControlsEnabled="True" AutoPlay="True" Visibility="Collapsed" />
It crashes on Stop()
, if I don't call that, then it crashes on VlcMediaPlayer.MediaSource = null;
. If I don't call that either, it crashes on the next time I try to set the MediaSource when starting.
The exception:
Unhandled exception at 0x774CF94D (ntdll.dll) in MyApp.exe: 0xC0000374: A heap has been corrupted (parameters: 0x7750B960).
I understand that something occurs when the media player is still playing and I try to stop it or remove the source, but what is the correct way to recycle the source?