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

Commit

Permalink
Added SetPause(bool) API
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyVignelles committed Oct 15, 2018
1 parent 421ddef commit b1b81bb
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Runtime.InteropServices;

namespace Vlc.DotNet.Core.Interops.Signatures
{
/// <summary>
/// Pause or resume (no effect if there is no media)
/// </summary>
[LibVlcFunction("libvlc_media_player_set_pause")]
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void SetPause(IntPtr mediaPlayerInstance, bool doPause);
}
15 changes: 15 additions & 0 deletions src/Vlc.DotNet.Core.Interops/VlcManager.SetPause.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using Vlc.DotNet.Core.Interops.Signatures;

namespace Vlc.DotNet.Core.Interops
{
public sealed partial class VlcManager
{
public void SetPause(VlcMediaPlayerInstance mediaPlayerInstance, bool isPause)
{
if (mediaPlayerInstance == IntPtr.Zero)
throw new ArgumentException("Media player instance is not initialized.");
GetInteropDelegate<SetPause>().Invoke(mediaPlayerInstance, isPause);
}
}
}
12 changes: 12 additions & 0 deletions src/Vlc.DotNet.Core/VlcMediaPlayer/VlcMediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,23 @@ public void Play(Stream stream, params string[] options)
this.Play();
}

/// <summary>
/// Toggle pause (no effect if there is no media)
/// </summary>
public void Pause()
{
Manager.Pause(myMediaPlayerInstance);
}

/// <summary>
/// Pause or resume (no effect if there is no media)
/// </summary>
/// <param name="doPause">If set to <c>true</c>, pauses the media, resumes if <c>false</c></param>
public void SetPause(bool doPause)
{
Manager.SetPause(myMediaPlayerInstance, doPause);
}

public void Stop()
{
Manager.Stop(myMediaPlayerInstance);
Expand Down
12 changes: 12 additions & 0 deletions src/Vlc.DotNet.Forms/VlcControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,23 @@ public void Play(Stream stream, params string[] options)
myVlcMediaPlayer?.Play(stream, options);
}

/// <summary>
/// Toggle pause (no effect if there is no media)
/// </summary>
public void Pause()
{
myVlcMediaPlayer?.Pause();
}

/// <summary>
/// Pause or resume (no effect if there is no media)
/// </summary>
/// <param name="doPause">If set to <c>true</c>, pauses the media, resumes if <c>false</c></param>
public void SetPause(bool doPause)
{
myVlcMediaPlayer?.SetPause(doPause);
}

public void Stop()
{
//EndInit();
Expand Down

0 comments on commit b1b81bb

Please sign in to comment.