Skip to content

Commit

Permalink
Add native ref check
Browse files Browse the repository at this point in the history
  • Loading branch information
mfkl committed May 11, 2021
1 parent d0fe5df commit 56b69d9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/LibVLCSharp/Shared/Media.cs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ MediaEventManager EventManager

/// <summary>Get duration (in ms) of media descriptor object item.</summary>
/// <returns>duration of media item or -1 on error</returns>
public long Duration => Native.LibVLCMediaGetDuration(NativeReference);
public long Duration => NativeReference == IntPtr.Zero ? -1 : Native.LibVLCMediaGetDuration(NativeReference);

/// <summary>
/// Parse the media asynchronously with options.
Expand Down Expand Up @@ -486,7 +486,7 @@ void OnParsedChanged(object sender, MediaParsedChangedEventArgs mediaParsedChang

/// <summary>Return true is the media descriptor object is parsed</summary>
/// <returns>true if media object has been parsed otherwise it returns false</returns>
public bool IsParsed => Native.LibVLCMediaIsParsed(NativeReference) != 0;
public bool IsParsed => NativeReference == IntPtr.Zero ? false : Native.LibVLCMediaIsParsed(NativeReference) != 0;

/// <summary>Get Parsed status for media descriptor object.</summary>
/// <returns>a value of the libvlc_media_parsed_status_t enum</returns>
Expand Down

0 comments on commit 56b69d9

Please sign in to comment.