...
 
Commits (2)
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using NUnit.Framework;
using VideoLAN.LibVLC;
using VideoLAN.LibVLC.Manual;
using MediaList = VideoLAN.LibVLC.Manual.MediaList;
namespace Bindings.Tests
{
[TestFixture]
public class MediaListPlayerTests
{
[Test]
public async Task Create()
{
//TODO: Fix me
var instance = new Instance();
var mediaListPlayer = new MediaListPlayer(instance);
var media = new Media(instance, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", Media.FromType.FromLocation);
Assert.AreEqual(VLCState.NothingSpecial, mediaListPlayer.State);
mediaListPlayer.MediaList = new MediaList(media);
mediaListPlayer.PlayItem(media);
await Task.Delay(5000);
Assert.True(mediaListPlayer.IsPlaying);
Assert.AreEqual(VLCState.Playing, mediaListPlayer.State);
}
}
}
\ No newline at end of file
// ----------------------------------------------------------------------------
// <auto-generated>
// This is autogenerated code by CppSharp.
// Do not edit this file or all your changes will be lost after re-generation.
// </auto-generated>
// ----------------------------------------------------------------------------
using System;
using System.Runtime.InteropServices;
using System.Security;
namespace VideoLAN.LibVLC
{
/// <summary>Defines playback modes for playlist.</summary>
public enum PlaybackMode
{
Default = 0,
Loop = 1,
Repeat = 2
}
/// <summary>The LibVLC media list player plays a</summary>
/// <remarks>
/// <para>in a certain order.</para>
/// <para>This is required to especially support playlist files.</para>
/// <para>The normal</para>
/// <para>single media, and does not handle playlist files properly.</para>
/// <para>@{</para>
/// <para></para>
/// <para>LibVLC media list player external API</para>
/// </remarks>
public unsafe partial class LibvlcMediaListPlayerT
{
[StructLayout(LayoutKind.Explicit, Size = 0)]
public partial struct __Internal
{
}
public global::System.IntPtr __Instance { get; protected set; }
protected int __PointerAdjustment;
internal static readonly global::System.Collections.Concurrent.ConcurrentDictionary<IntPtr, global::VideoLAN.LibVLC.LibvlcMediaListPlayerT> NativeToManagedMap = new global::System.Collections.Concurrent.ConcurrentDictionary<IntPtr, global::VideoLAN.LibVLC.LibvlcMediaListPlayerT>();
protected void*[] __OriginalVTables;
protected bool __ownsNativeInstance;
internal static global::VideoLAN.LibVLC.LibvlcMediaListPlayerT __CreateInstance(global::System.IntPtr native, bool skipVTables = false)
{
return new global::VideoLAN.LibVLC.LibvlcMediaListPlayerT(native.ToPointer(), skipVTables);
}
internal static global::VideoLAN.LibVLC.LibvlcMediaListPlayerT __CreateInstance(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT.__Internal native, bool skipVTables = false)
{
return new global::VideoLAN.LibVLC.LibvlcMediaListPlayerT(native, skipVTables);
}
private static void* __CopyValue(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT.__Internal native)
{
var ret = Marshal.AllocHGlobal(sizeof(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT.__Internal));
*(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT.__Internal*) ret = native;
return ret.ToPointer();
}
private LibvlcMediaListPlayerT(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT.__Internal native, bool skipVTables = false)
: this(__CopyValue(native), skipVTables)
{
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
}
protected LibvlcMediaListPlayerT(void* native, bool skipVTables = false)
{
if (native == null)
return;
__Instance = new global::System.IntPtr(native);
}
}
public unsafe partial class libvlc_media_list_player
{
public partial struct __Internal
{
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="libvlc_media_list_player_new")]
internal static extern global::System.IntPtr LibvlcMediaListPlayerNew(global::System.IntPtr p_instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="libvlc_media_list_player_release")]
internal static extern void LibvlcMediaListPlayerRelease(global::System.IntPtr p_mlp);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="libvlc_media_list_player_retain")]
internal static extern void LibvlcMediaListPlayerRetain(global::System.IntPtr p_mlp);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="libvlc_media_list_player_event_manager")]
internal static extern global::System.IntPtr LibvlcMediaListPlayerEventManager(global::System.IntPtr p_mlp);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="libvlc_media_list_player_set_media_player")]
internal static extern void LibvlcMediaListPlayerSetMediaPlayer(global::System.IntPtr p_mlp, global::System.IntPtr p_mi);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="libvlc_media_list_player_get_media_player")]
internal static extern global::System.IntPtr LibvlcMediaListPlayerGetMediaPlayer(global::System.IntPtr p_mlp);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="libvlc_media_list_player_set_media_list")]
internal static extern void LibvlcMediaListPlayerSetMediaList(global::System.IntPtr p_mlp, global::System.IntPtr p_mlist);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="libvlc_media_list_player_play")]
internal static extern void LibvlcMediaListPlayerPlay(global::System.IntPtr p_mlp);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="libvlc_media_list_player_pause")]
internal static extern void LibvlcMediaListPlayerPause(global::System.IntPtr p_mlp);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="libvlc_media_list_player_is_playing")]
internal static extern int LibvlcMediaListPlayerIsPlaying(global::System.IntPtr p_mlp);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="libvlc_media_list_player_get_state")]
internal static extern global::VideoLAN.LibVLC.VLCState LibvlcMediaListPlayerGetState(global::System.IntPtr p_mlp);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="libvlc_media_list_player_play_item_at_index")]
internal static extern int LibvlcMediaListPlayerPlayItemAtIndex(global::System.IntPtr p_mlp, int i_index);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="libvlc_media_list_player_play_item")]
internal static extern int LibvlcMediaListPlayerPlayItem(global::System.IntPtr p_mlp, global::System.IntPtr p_md);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="libvlc_media_list_player_stop")]
internal static extern void LibvlcMediaListPlayerStop(global::System.IntPtr p_mlp);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="libvlc_media_list_player_next")]
internal static extern int LibvlcMediaListPlayerNext(global::System.IntPtr p_mlp);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="libvlc_media_list_player_previous")]
internal static extern int LibvlcMediaListPlayerPrevious(global::System.IntPtr p_mlp);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="libvlc_media_list_player_set_playback_mode")]
internal static extern void LibvlcMediaListPlayerSetPlaybackMode(global::System.IntPtr p_mlp, global::VideoLAN.LibVLC.PlaybackMode e_mode);
}
/// <summary>Create new media_list_player.</summary>
/// <param name="p_instance">libvlc instance</param>
/// <returns>media list player instance or NULL on error</returns>
public static global::VideoLAN.LibVLC.LibvlcMediaListPlayerT LibvlcMediaListPlayerNew(global::VideoLAN.LibVLC.Manual.Instance p_instance)
{
var __arg0 = ReferenceEquals(p_instance, null) ? global::System.IntPtr.Zero : p_instance.NativeReference;
var __ret = __Internal.LibvlcMediaListPlayerNew(__arg0);
global::VideoLAN.LibVLC.LibvlcMediaListPlayerT __result0;
if (__ret == IntPtr.Zero) __result0 = null;
else if (global::VideoLAN.LibVLC.LibvlcMediaListPlayerT.NativeToManagedMap.ContainsKey(__ret))
__result0 = (global::VideoLAN.LibVLC.LibvlcMediaListPlayerT) global::VideoLAN.LibVLC.LibvlcMediaListPlayerT.NativeToManagedMap[__ret];
else __result0 = global::VideoLAN.LibVLC.LibvlcMediaListPlayerT.__CreateInstance(__ret);
return __result0;
}
/// <summary>
/// <para>Release a media_list_player after use</para>
/// <para>Decrement the reference count of a media player object. If the</para>
/// <para>reference count is 0, then libvlc_media_list_player_release() will</para>
/// <para>release the media player object. If the media player object</para>
/// <para>has been released, then it should not be used again.</para>
/// </summary>
/// <param name="p_mlp">media list player instance</param>
public static void LibvlcMediaListPlayerRelease(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT p_mlp)
{
var __arg0 = ReferenceEquals(p_mlp, null) ? global::System.IntPtr.Zero : p_mlp.__Instance;
__Internal.LibvlcMediaListPlayerRelease(__arg0);
}
/// <summary>
/// <para>Retain a reference to a media player list object. Use</para>
/// <para>libvlc_media_list_player_release() to decrement reference count.</para>
/// </summary>
/// <param name="p_mlp">media player list object</param>
public static void LibvlcMediaListPlayerRetain(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT p_mlp)
{
var __arg0 = ReferenceEquals(p_mlp, null) ? global::System.IntPtr.Zero : p_mlp.__Instance;
__Internal.LibvlcMediaListPlayerRetain(__arg0);
}
/// <summary>Return the event manager of this media_list_player.</summary>
/// <param name="p_mlp">media list player instance</param>
/// <returns>the event manager</returns>
//public static global::VideoLAN.LibVLC.EventManager LibvlcMediaListPlayerEventManager(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT p_mlp)
//{
// var __arg0 = ReferenceEquals(p_mlp, null) ? global::System.IntPtr.Zero : p_mlp.NativeReference;
// var __ret = __Internal.LibvlcMediaListPlayerEventManager(__arg0);
// global::VideoLAN.LibVLC.EventManager __result0;
// if (__ret == IntPtr.Zero) __result0 = null;
// else if (global::VideoLAN.LibVLC.EventManager.NativeToManagedMap.ContainsKey(__ret))
// __result0 = (global::VideoLAN.LibVLC.EventManager) global::VideoLAN.LibVLC.EventManager.NativeToManagedMap[__ret];
// else __result0 = global::VideoLAN.LibVLC.EventManager.__CreateInstance(__ret);
// return __result0;
//}
/// <summary>Replace media player in media_list_player with this instance.</summary>
/// <param name="p_mlp">media list player instance</param>
/// <param name="p_mi">media player instance</param>
//public static void LibvlcMediaListPlayerSetMediaPlayer(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT p_mlp, global::VideoLAN.LibVLC.MediaPlayer p_mi)
//{
// var __arg0 = ReferenceEquals(p_mlp, null) ? global::System.IntPtr.Zero : p_mlp.__Instance;
// var __arg1 = ReferenceEquals(p_mi, null) ? global::System.IntPtr.Zero : p_mi.__Instance;
// __Internal.LibvlcMediaListPlayerSetMediaPlayer(__arg0, __arg1);
//}
///// <summary>Get media player of the media_list_player instance.</summary>
///// <param name="p_mlp">media list player instance</param>
///// <returns>media player instance</returns>
///// <remarks>the caller is responsible for releasing the returned instance</remarks>
//public static global::VideoLAN.LibVLC.MediaPlayer LibvlcMediaListPlayerGetMediaPlayer(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT p_mlp)
//{
// var __arg0 = ReferenceEquals(p_mlp, null) ? global::System.IntPtr.Zero : p_mlp.__Instance;
// var __ret = __Internal.LibvlcMediaListPlayerGetMediaPlayer(__arg0);
// global::VideoLAN.LibVLC.MediaPlayer __result0;
// if (__ret == IntPtr.Zero) __result0 = null;
// else if (global::VideoLAN.LibVLC.MediaPlayer.NativeToManagedMap.ContainsKey(__ret))
// __result0 = (global::VideoLAN.LibVLC.MediaPlayer) global::VideoLAN.LibVLC.MediaPlayer.NativeToManagedMap[__ret];
// else __result0 = global::VideoLAN.LibVLC.MediaPlayer.__CreateInstance(__ret);
// return __result0;
//}
/// <summary>Set the media list associated with the player</summary>
/// <param name="p_mlp">media list player instance</param>
/// <param name="p_mlist">list of media</param>
public static void LibvlcMediaListPlayerSetMediaList(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT p_mlp, global::VideoLAN.LibVLC.MediaList p_mlist)
{
var __arg0 = ReferenceEquals(p_mlp, null) ? global::System.IntPtr.Zero : p_mlp.__Instance;
var __arg1 = ReferenceEquals(p_mlist, null) ? global::System.IntPtr.Zero : p_mlist.__Instance;
__Internal.LibvlcMediaListPlayerSetMediaList(__arg0, __arg1);
}
/// <summary>Play media list</summary>
/// <param name="p_mlp">media list player instance</param>
public static void LibvlcMediaListPlayerPlay(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT p_mlp)
{
var __arg0 = ReferenceEquals(p_mlp, null) ? global::System.IntPtr.Zero : p_mlp.__Instance;
__Internal.LibvlcMediaListPlayerPlay(__arg0);
}
/// <summary>Toggle pause (or resume) media list</summary>
/// <param name="p_mlp">media list player instance</param>
public static void LibvlcMediaListPlayerPause(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT p_mlp)
{
var __arg0 = ReferenceEquals(p_mlp, null) ? global::System.IntPtr.Zero : p_mlp.__Instance;
__Internal.LibvlcMediaListPlayerPause(__arg0);
}
/// <summary>Is media list playing?</summary>
/// <param name="p_mlp">media list player instance</param>
/// <returns>true for playing and false for not playing</returns>
public static int LibvlcMediaListPlayerIsPlaying(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT p_mlp)
{
var __arg0 = ReferenceEquals(p_mlp, null) ? global::System.IntPtr.Zero : p_mlp.__Instance;
var __ret = __Internal.LibvlcMediaListPlayerIsPlaying(__arg0);
return __ret;
}
/// <summary>Get current libvlc_state of media list player</summary>
/// <param name="p_mlp">media list player instance</param>
/// <returns>libvlc_state_t for media list player</returns>
public static global::VideoLAN.LibVLC.VLCState LibvlcMediaListPlayerGetState(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT p_mlp)
{
var __arg0 = ReferenceEquals(p_mlp, null) ? global::System.IntPtr.Zero : p_mlp.__Instance;
var __ret = __Internal.LibvlcMediaListPlayerGetState(__arg0);
return __ret;
}
/// <summary>Play media list item at position index</summary>
/// <param name="p_mlp">media list player instance</param>
/// <param name="i_index">index in media list to play</param>
/// <returns>0 upon success -1 if the item wasn't found</returns>
public static int LibvlcMediaListPlayerPlayItemAtIndex(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT p_mlp, int i_index)
{
var __arg0 = ReferenceEquals(p_mlp, null) ? global::System.IntPtr.Zero : p_mlp.__Instance;
var __ret = __Internal.LibvlcMediaListPlayerPlayItemAtIndex(__arg0, i_index);
return __ret;
}
/// <summary>Play the given media item</summary>
/// <param name="p_mlp">media list player instance</param>
/// <param name="p_md">the media instance</param>
/// <returns>0 upon success, -1 if the media is not part of the media list</returns>
public static int LibvlcMediaListPlayerPlayItem(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT p_mlp, global::VideoLAN.LibVLC.Media p_md)
{
var __arg0 = ReferenceEquals(p_mlp, null) ? global::System.IntPtr.Zero : p_mlp.__Instance;
var __arg1 = ReferenceEquals(p_md, null) ? global::System.IntPtr.Zero : p_md.NativeReference;
var __ret = __Internal.LibvlcMediaListPlayerPlayItem(__arg0, __arg1);
return __ret;
}
/// <summary>Stop playing media list</summary>
/// <param name="p_mlp">media list player instance</param>
public static void LibvlcMediaListPlayerStop(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT p_mlp)
{
var __arg0 = ReferenceEquals(p_mlp, null) ? global::System.IntPtr.Zero : p_mlp.__Instance;
__Internal.LibvlcMediaListPlayerStop(__arg0);
}
/// <summary>Play next item from media list</summary>
/// <param name="p_mlp">media list player instance</param>
/// <returns>0 upon success -1 if there is no next item</returns>
public static int LibvlcMediaListPlayerNext(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT p_mlp)
{
var __arg0 = ReferenceEquals(p_mlp, null) ? global::System.IntPtr.Zero : p_mlp.__Instance;
var __ret = __Internal.LibvlcMediaListPlayerNext(__arg0);
return __ret;
}
/// <summary>Play previous item from media list</summary>
/// <param name="p_mlp">media list player instance</param>
/// <returns>0 upon success -1 if there is no previous item</returns>
public static int LibvlcMediaListPlayerPrevious(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT p_mlp)
{
var __arg0 = ReferenceEquals(p_mlp, null) ? global::System.IntPtr.Zero : p_mlp.__Instance;
var __ret = __Internal.LibvlcMediaListPlayerPrevious(__arg0);
return __ret;
}
/// <summary>Sets the playback mode for the playlist</summary>
/// <param name="p_mlp">media list player instance</param>
/// <param name="e_mode">playback mode specification</param>
public static void LibvlcMediaListPlayerSetPlaybackMode(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT p_mlp, global::VideoLAN.LibVLC.PlaybackMode e_mode)
{
var __arg0 = ReferenceEquals(p_mlp, null) ? global::System.IntPtr.Zero : p_mlp.__Instance;
__Internal.LibvlcMediaListPlayerSetPlaybackMode(__arg0, e_mode);
}
}
}
using System;
using System.Runtime.InteropServices;
using System.Security;
namespace VideoLAN.LibVLC.Manual
{
public class MediaListPlayer : Internal
{
MediaListEventManager _eventManager;
struct Native
{
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_list_player_new")]
internal static extern IntPtr LibVLCMediaListPlayerNew(IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_list_player_release")]
internal static extern void LibVLCMediaListPlayerRelease(IntPtr mediaListPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_list_player_event_manager")]
internal static extern IntPtr LibVLCMediaListPlayerEventManager(IntPtr mediaListPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_list_player_set_media_player")]
internal static extern void LibVLCMediaListPlayerSetMediaPlayer(IntPtr mediaListPlayer, IntPtr mediaPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_list_player_set_media_list")]
internal static extern void LibVLCMediaListPlayerSetMediaList(IntPtr mediaListPlayer, IntPtr mediaList);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_list_player_play")]
internal static extern void LibVLCMediaListPlayerPlay(IntPtr mediaListPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_list_player_pause")]
internal static extern void LibVLCMediaListPlayerPause(IntPtr mediaListPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_list_player_is_playing")]
internal static extern int LibVLCMediaListPlayerIsPlaying(IntPtr mediaListPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_list_player_get_state")]
internal static extern VLCState LibVLCMediaListPlayerGetState(IntPtr mediaListPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_list_player_play_item_at_index")]
internal static extern int LibVLCMediaListPlayerPlayItemAtIndex(IntPtr mediaListPlayer, int index);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_list_player_play_item")]
internal static extern int LibVLCMediaListPlayerPlayItem(IntPtr mediaListPlayer, IntPtr media);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_list_player_stop")]
internal static extern void LibVLCMediaListPlayerStop(IntPtr mediaListPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_list_player_next")]
internal static extern int LibVLCMediaListPlayerNext(IntPtr mediaListPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_list_player_previous")]
internal static extern int LibVLCMediaListPlayerPrevious(IntPtr mediaListPlayer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_list_player_set_playback_mode")]
internal static extern void LibVLCMediaListPlayerSetPlaybackMode(IntPtr mediaListPlayer, PlaybackMode mode);
}
public MediaListPlayer(Instance instance)
: base(() => Native.LibVLCMediaListPlayerNew(instance.NativeReference), Native.LibVLCMediaListPlayerRelease)
{
}
/// <summary>Return the event manager of this media_list_player.</summary>
/// <returns>the event manager</returns>
public MediaListEventManager EventManager
{
get
{
if (_eventManager == null)
{
var ptr = Native.LibVLCMediaListPlayerEventManager(NativeReference);
_eventManager = new MediaListEventManager(ptr);
}
return _eventManager;
}
}
/// <summary>Replace media player in media_list_player with this instance.</summary>
public MediaPlayer MediaPlayer
{
set => Native.LibVLCMediaListPlayerSetMediaPlayer(NativeReference, value.NativeReference);
}
/// <summary>Set the media list associated with the player</summary>
public MediaList MediaList
{
set => Native.LibVLCMediaListPlayerSetMediaList(NativeReference, value.NativeReference);
}
/// <summary>Play media list</summary>
public void Play()
{
Native.LibVLCMediaListPlayerPlay(NativeReference);
}
/// <summary>Toggle pause (or resume) media list</summary>
public void Pause()
{
Native.LibVLCMediaListPlayerPause(NativeReference);
}
/// <summary>Is media list playing?</summary>
public bool IsPlaying => Native.LibVLCMediaListPlayerIsPlaying(NativeReference) != 0;
/// <summary>
/// Get current libvlc_state of media list player
/// </summary>
public VLCState State => Native.LibVLCMediaListPlayerGetState(NativeReference);
/// <summary>
/// Play media list item at position index
/// </summary>
/// <param name="index">index in media list to play</param>
public bool PlayItemAtIndex(int index) =>
Native.LibVLCMediaListPlayerPlayItemAtIndex(NativeReference, index) == 0;
/// <summary>
/// Play the given media item
/// </summary>
/// <param name="media">the media instance</param>
public bool PlayItem(Media media) =>
Native.LibVLCMediaListPlayerPlayItem(NativeReference, media.NativeReference) == 0;
/// <summary>
/// Stop playing media list
/// </summary>
public void Stop() => Native.LibVLCMediaListPlayerStop(NativeReference);
/// <summary>
/// Play next item from media list
/// </summary>
public bool Next() => Native.LibVLCMediaListPlayerNext(NativeReference) == 0;
/// <summary>
/// Play previous item from media list
/// </summary>
public bool Previous() => Native.LibVLCMediaListPlayerPrevious(NativeReference) == 0;
/// <summary>
/// Sets the playback mode for the playlist
/// </summary>
public PlaybackMode PlaybackMode
{
set => Native.LibVLCMediaListPlayerSetPlaybackMode(NativeReference, value);
}
}
/// <summary>Defines playback modes for playlist.</summary>
public enum PlaybackMode
{
Default = 0,
Loop = 1,
Repeat = 2
}
}
\ No newline at end of file