Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Commit

Permalink
Added the ResetMedia method
Browse files Browse the repository at this point in the history
Fixes #535
  • Loading branch information
jeremyVignelles committed Mar 27, 2019
1 parent c916f66 commit 0b48ffc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ public void SetMediaToMediaPlayer(VlcMediaPlayerInstance mediaPlayerInstance, Vl
{
if (mediaPlayerInstance == IntPtr.Zero)
throw new ArgumentException("Media player instance is not initialized.");
if (mediaInstance == IntPtr.Zero)
throw new ArgumentException("Media instance is not initialized.");
myLibraryLoader.GetInteropDelegate<SetMediaToMediaPlayer>().Invoke(mediaPlayerInstance, mediaInstance);
myLibraryLoader.GetInteropDelegate<SetMediaToMediaPlayer>().Invoke(mediaPlayerInstance, mediaInstance?.Pointer ?? IntPtr.Zero);
}
}
}
9 changes: 7 additions & 2 deletions src/Vlc.DotNet.Core/VlcMediaPlayer/VlcMediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,21 @@ public VlcMedia SetMedia(Stream stream, params string[] options)
return SetMedia(new VlcMedia(this, stream, options));
}

public void ResetMedia()
{
SetMedia((VlcMedia)null);
}

private VlcMedia SetMedia(VlcMedia media)
{
// If there is a previous media, dispose it.
myCurrentMedia?.Dispose();

// Set it to the media player.
Manager.SetMediaToMediaPlayer(myMediaPlayerInstance, media.MediaInstance);
Manager.SetMediaToMediaPlayer(myMediaPlayerInstance, media?.MediaInstance);

// Register Events.
media.Initialize();
media?.Initialize();
myCurrentMedia = media;

return media;
Expand Down
5 changes: 5 additions & 0 deletions src/Vlc.DotNet.Forms/VlcControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,11 @@ public void SetMedia(Stream stream, params string[] options)
//EndInit();
myVlcMediaPlayer.SetMedia(stream, options);
}

public void ResetMedia()
{
myVlcMediaPlayer.ResetMedia();
}
#endregion
}
}

0 comments on commit 0b48ffc

Please sign in to comment.