From: RĂ©mi Denis-Courmont Date: Sun, 21 Oct 2007 12:55:32 +0000 (+0000) Subject: Basic playlist controls X-Git-Tag: 0.9.0-test0~4885 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=54f91faac813fba2cb8b94fdc11ee977a9a94c66;p=vlc Basic playlist controls --- diff --git a/bindings/cil/libvlc.cs b/bindings/cil/libvlc.cs index 0bd4cebf2e..f460831062 100644 --- a/bindings/cil/libvlc.cs +++ b/bindings/cil/libvlc.cs @@ -64,6 +64,9 @@ namespace VideoLAN.LibVLC } }; + /** + * Managed class for LibVLC instance (including playlist) + */ public class Instance : BaseObject { internal Instance (InstanceHandle self) : base (self) @@ -78,6 +81,113 @@ namespace VideoLAN.LibVLC return new MediaDescriptor (dh); } + + + [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_loop")] + static extern void PlaylistLoop (InstanceHandle self, int b, + NativeException ex); + /** Sets the playlist loop flag */ + public bool Loop + { + set + { + PlaylistLoop (self, value ? 1 : 0, ex); + ex.Raise (); + } + } + + [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_play")] + static extern void PlaylistPlay (InstanceHandle self, int id, int optc, + U8String[] optv, NativeException ex); + /** Plays the next playlist item */ + public void Play () + { + PlaylistPlay (self, -1, 0, new U8String[0], ex); + ex.Raise (); + } + + [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_pause")] + static extern void PlaylistPause (InstanceHandle self, + NativeException ex); + /** Toggles pause */ + public void TogglePause () + { + PlaylistPause (self, ex); + ex.Raise (); + } + + [DllImport ("libvlc-control.dll", + EntryPoint="libvlc_playlist_isplaying")] + static extern int PlaylistIsPlaying (InstanceHandle self, + NativeException ex); + /** Whether the playlist is running, or in pause/stop */ + public bool IsPlaying + { + get + { + int ret = PlaylistIsPlaying (self, ex); + ex.Raise (); + return ret != 0; + } + } + + [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_stop")] + static extern void PlaylistStop (InstanceHandle self, + NativeException ex); + /** Stops playing */ + public void Stop () + { + PlaylistStop (self, ex); + ex.Raise (); + } + + [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_next")] + static extern void PlaylistNext (InstanceHandle self, + NativeException ex); + /** Goes to next playlist item (and start playing it) */ + public void Next () + { + PlaylistNext (self, ex); + ex.Raise (); + } + + [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_prev")] + static extern void PlaylistPrev (InstanceHandle self, + NativeException ex); + /** Goes to previous playlist item (and start playing it) */ + public void Prev () + { + PlaylistPrev (self, ex); + ex.Raise (); + } + + [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_clear")] + static extern void PlaylistClear (InstanceHandle self, + NativeException ex); + /** Clears the whole playlist */ + public void Clear () + { + PlaylistClear (self, ex); + ex.Raise (); + } + + [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_add")] + static extern void PlaylistAdd (InstanceHandle self, U8String uri, + U8String name, NativeException e); + /** Appends an item to the playlist */ + public void Add (string mrl) + { + Add (mrl, null); + } + /** Appends an item to the playlist */ + public void Add (string mrl, string name) + { + U8String umrl = new U8String (mrl); + U8String uname = new U8String (name); + + PlaylistAdd (self, umrl, uname, ex); + ex.Raise (); + } }; /** Safe handle for unmanaged LibVLC media descriptor */ diff --git a/bindings/cil/testvlc.cs b/bindings/cil/testvlc.cs index 4fa204b554..43219d31b9 100644 --- a/bindings/cil/testvlc.cs +++ b/bindings/cil/testvlc.cs @@ -34,8 +34,14 @@ namespace VideoLAN.LibVLC.Test Instance vlc = VLC.CreateInstance (argv); MediaDescriptor md = vlc.CreateDescriptor (args[0]); - md.Dispose (); + + foreach (string s in args) + vlc.Add (s); + + vlc.Loop = false; + vlc.TogglePause (); + Console.ReadLine (); vlc.Dispose (); return 0; } diff --git a/bindings/cil/ustring.cs b/bindings/cil/ustring.cs index e64d53dadc..7175d00b95 100644 --- a/bindings/cil/ustring.cs +++ b/bindings/cil/ustring.cs @@ -36,6 +36,9 @@ namespace VideoLAN.LibVLC public U8String (string value) { + if (value == null) + return; + byte[] bytes = System.Text.Encoding.UTF8.GetBytes (value); mb_str = new byte[bytes.Length + 1]; Array.Copy (bytes, mb_str, bytes.Length);