Skip to content

Commit

Permalink
add media retain
Browse files Browse the repository at this point in the history
  • Loading branch information
mfkl committed May 11, 2021
1 parent 744124d commit d0fe5df
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/LibVLCSharp/Shared/MediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -631,20 +631,23 @@ public MediaPlayer(Media media)
/// </summary>
public Media? Media
{
get
{
return _media;
}
get => _media;
set
{
if(_media?.NativeReference != IntPtr.Zero)
if(_media != null)
{
_media?.Dispose();
_media.Dispose();
_media = null;
}

_media = value;
Native.LibVLCMediaPlayerSetMedia(NativeReference, value?.NativeReference ?? IntPtr.Zero);

if(_media != null)
{
_media.Retain();
}

Native.LibVLCMediaPlayerSetMedia(NativeReference, _media?.NativeReference ?? IntPtr.Zero);
}
}

Expand Down

0 comments on commit d0fe5df

Please sign in to comment.