Skip to content

Commit 84250eb

Browse files
committed
Add native ref check
1 parent d1d0a89 commit 84250eb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/LibVLCSharp/Shared/Media.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ MediaEventManager EventManager
436436

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

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

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

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

0 commit comments

Comments
 (0)