]> git.sesse.net Git - vlc/commitdiff
Mostly implement media player
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 21 Feb 2009 16:14:05 +0000 (18:14 +0200)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 21 Feb 2009 16:15:09 +0000 (18:15 +0200)
bindings/cil/src/libvlc.cs
bindings/cil/src/player.cs

index 157a32b38c7f9ba92fe1a1c19e46ec3d97ebec70..570d189f9fbfb39bd86fce5b3a718ddd7e010066 100644 (file)
@@ -202,8 +202,7 @@ namespace VideoLAN.LibVLC
         [DllImport ("libvlc.dll",
                     EntryPoint="libvlc_media_player_get_xwindow")]
         public static extern
-        int PlayerGetXWindow (PlayerHandle player,
-                              NativeException ex);
+        int PlayerGetXWindow (PlayerHandle player);
 
         [DllImport ("libvlc.dll",
                     EntryPoint="libvlc_media_player_set_hwnd")]
@@ -214,7 +213,7 @@ namespace VideoLAN.LibVLC
         [DllImport ("libvlc.dll",
                     EntryPoint="libvlc_media_player_get_hwnd")]
         public static extern
-        IntPtr PlayerGetHWND (PlayerHandle player, NativeException ex);
+        SafeHandle PlayerGetHWND (PlayerHandle player);
 
         [DllImport ("libvlc.dll",
                     EntryPoint="libvlc_media_player_get_length")]
@@ -255,8 +254,78 @@ namespace VideoLAN.LibVLC
         [DllImport ("libvlc.dll",
                     EntryPoint="libvlc_media_player_get_chapter_count")]
         public static extern
-        int PlayerGetChapterCounter (PlayerHandle player, NativeException ex);
+        int PlayerGetChapterCount (PlayerHandle player, NativeException ex);
 
         /* PlayerWillPlay */
+
+        [DllImport ("libvlc.dll",
+                EntryPoint="libvlc_media_player_get_chapter_count_for_title")]
+        public static extern
+        int PlayerGetChapterCountForTitle (PlayerHandle player, int title,
+                                           NativeException ex);
+
+        [DllImport ("libvlc.dll",
+                    EntryPoint="libvlc_media_player_get_title")]
+        public static extern
+        int PlayerGetTitle (PlayerHandle player, NativeException ex);
+
+        [DllImport ("libvlc.dll",
+                    EntryPoint="libvlc_media_player_set_title")]
+        public static extern
+        void PlayerSetTitle (PlayerHandle player, int chapter,
+                             NativeException ex);
+
+        [DllImport ("libvlc.dll",
+                    EntryPoint="libvlc_media_player_get_title_count")]
+        public static extern
+        int PlayerGetTitleCount (PlayerHandle player, NativeException ex);
+
+        [DllImport ("libvlc.dll",
+                    EntryPoint="libvlc_media_player_next_chapter")]
+        public static extern
+        void PlayerNextChapter (PlayerHandle player, NativeException ex);
+
+        [DllImport ("libvlc.dll",
+                    EntryPoint="libvlc_media_player_previous_chapter")]
+        public static extern
+        void PlayerPreviousChapter (PlayerHandle player, NativeException ex);
+
+        [DllImport ("libvlc.dll",
+                    EntryPoint="libvlc_media_player_get_rate")]
+        public static extern
+        float PlayerGetRate (PlayerHandle player, NativeException ex);
+
+        [DllImport ("libvlc.dll",
+                    EntryPoint="libvlc_media_player_set_rate")]
+        public static extern
+        void PlayerSetRate (PlayerHandle player, float rate,
+                            NativeException ex);
+
+        /*[DllImport ("libvlc.dll",
+                    EntryPoint="libvlc_media_player_get_state")]
+        public static extern
+        void PlayerSetState (PlayerHandle player, float rate,
+                             NativeException ex); */
+
+        [DllImport ("libvlc.dll",
+                    EntryPoint="libvlc_media_player_get_fps")]
+        public static extern
+        float PlayerGetFPS (PlayerHandle player, NativeException ex);
+
+        [DllImport ("libvlc.dll",
+                    EntryPoint="libvlc_media_player_has_vout")]
+        public static extern
+        int PlayerHasVout (PlayerHandle player, NativeException ex);
+
+        [DllImport ("libvlc.dll",
+                    EntryPoint="libvlc_media_player_is_seekable")]
+        public static extern
+        int PlayerIsSeekable (PlayerHandle player, NativeException ex);
+
+        [DllImport ("libvlc.dll",
+                    EntryPoint="libvlc_media_player_can_pause")]
+        public static extern
+        int PlayerCanPause (PlayerHandle player, NativeException ex);
+
     };
 };
index 3e8c80ea86b5297aa50b1f199c80aca1ba414e2a..fb17b1efa76866aed41871af0f89a589323e3e03 100644 (file)
@@ -106,5 +106,315 @@ namespace VideoLAN.LibVLC
             Raise ();
         }
 
+        /**
+         * Whether the player is currently active.
+         */
+        public bool IsPlaying
+        {
+            get
+            {
+                int ret = LibVLC.PlayerIsPlaying (Handle, ex);
+                Raise ();
+                return ret != 0;
+            }
+        }
+
+        /**
+         * Starts playing the selected media.
+         */
+        public void Play ()
+        {
+            LibVLC.PlayerPlay (Handle, ex);
+            Raise ();
+        }
+
+        /**
+         * Pauses the playback.
+         */
+        public void Pause ()
+        {
+            LibVLC.PlayerPause (Handle, ex);
+            Raise ();
+        }
+
+        /**
+         * Stops the playback.
+         */
+        public void Stop ()
+        {
+            LibVLC.PlayerStop (Handle, ex);
+            Raise ();
+        }
+
+        /**
+         * The 32-bits identifier of an X Window System window,
+         * or 0 if not specified.
+         * Video will be rendered inside that window, if the underlying VLC
+         * supports X11. Note that X pixmaps are <b>not</b> supported.
+         * Also note that you should set/change/unset the window while
+         * playback is not started or stopped; live reparenting might not
+         * work.
+         *
+         * <b>Warning:</b>
+         * If the identifier is invalid, Xlib might abort the process.
+         */
+        public int XWindow
+        {
+            get
+            {
+                return LibVLC.PlayerGetXWindow (Handle);
+            }
+            set
+            {
+                LibVLC.PlayerSetXWindow (Handle, value, ex);
+                Raise ();
+            }
+        }
+
+        /**
+         * The handle of a window (HWND) from the Win32 API,
+         * or NULL if unspecified.
+         * Video will be rendered inside that window, if the underlying VLC
+         * supports one of DirectDraw, Direct3D, GDI or OpenGL/Win32.
+         * Note that you should set/change/unset the window while playback is
+         * not started or stopped; live reparenting might not work.
+         */
+        public SafeHandle HWND
+        {
+            get
+            {
+                return LibVLC.PlayerGetHWND (Handle);
+            }
+            set
+            {
+                LibVLC.PlayerSetHWND (Handle, value, ex);
+                Raise ();
+            }
+        }
+
+        /**
+         * Total length in microseconds of the playback (if known).
+         */
+        public long Length
+        {
+            get
+            {
+                long ret = LibVLC.PlayerGetLength (Handle, ex);
+                Raise ();
+                return ret;
+            }
+        }
+
+        /**
+         * Playback position in microseconds from the start (if applicable).
+         * Setting this value might not work depending on the underlying
+         * media capability and file format.
+         *
+         * Changing the Time will also change the Position.
+         */
+        public long Time
+        {
+            get
+            {
+                long ret = LibVLC.PlayerGetTime (Handle, ex);
+                Raise ();
+                return ret;
+            }
+            set
+            {
+                LibVLC.PlayerSetTime (Handle, value, ex);
+                Raise ();
+            }
+        }
+
+        /**
+         * Playback position as a fraction of the total (if applicable).
+         * Setting this value might not work depending on the underlying
+         * media capability and file format.
+         *
+         * Changing the Position will also change the Time.
+         */
+        public float Position
+        {
+            get
+            {
+                float ret = LibVLC.PlayerGetPosition (Handle, ex);
+                Raise ();
+                return ret;
+            }
+            set
+            {
+                LibVLC.PlayerSetPosition (Handle, value, ex);
+                Raise ();
+            }
+        }
+
+        /**
+         * Number of the current chapter (within the current title).
+         * This is mostly used for DVDs and the likes.
+         */
+        public int Chapter
+        {
+            get
+            {
+                int ret = LibVLC.PlayerGetChapter (Handle, ex);
+                Raise ();
+                return ret;
+            }
+            set
+            {
+                LibVLC.PlayerSetChapter (Handle, value, ex);
+                Raise ();
+            }
+        }
+
+        /**
+         * Number of chapters within the current title,
+         */
+        public int ChapterCount
+        {
+            get
+            {
+                int ret = LibVLC.PlayerGetChapterCount (Handle, ex);
+                Raise ();
+                return ret;
+            }
+        }
+
+        /**
+         * Gets the number of chapters within a given title.
+         * @param title media title number
+         */
+        public int GetChapterCountByTitle (int title)
+        {
+            int ret = LibVLC.PlayerGetChapterCountForTitle (Handle, title, ex);
+            Raise ();
+            return ret;
+        }
+
+        /**
+         * Number of the current title.
+         */
+        public int Title
+        {
+            get
+            {
+                int ret = LibVLC.PlayerGetTitle (Handle, ex);
+                Raise ();
+                return ret;
+            }
+            set
+            {
+                LibVLC.PlayerSetTitle (Handle, value, ex);
+                Raise ();
+            }
+        }
+
+        /**
+         * Total number of titles.
+         */
+        public int TitleCount
+        {
+            get
+            {
+                int ret = LibVLC.PlayerGetTitleCount (Handle, ex);
+                Raise ();
+                return ret;
+            }
+        }
+
+        /**
+         * Skips to the beginning of the next chapter.
+         */
+        public void NextChapter ()
+        {
+            LibVLC.PlayerNextChapter (Handle, ex);
+            Raise ();
+        }
+
+        /**
+         * Rewinds to the previous chapter.
+         */
+        public void PreviousChapter ()
+        {
+            LibVLC.PlayerPreviousChapter (Handle, ex);
+            Raise ();
+        }
+
+        /**
+         * Media playback rate.
+         * 1.0 is the nominal rate.
+         * Less than one is slower than nominal.
+         * More than one is faster than nominal.
+         */
+        public float Rate
+        {
+            get
+            {
+                float ret = LibVLC.PlayerGetRate (Handle, ex);
+                Raise ();
+                return ret;
+            }
+            set
+            {
+                LibVLC.PlayerSetRate (Handle, value, ex);
+                Raise ();
+            }
+        }
+
+        /**
+         * Frame rate in unit/seconds.
+         */
+        public float FramePerSeconds
+        {
+            get
+            {
+                float ret = LibVLC.PlayerGetFPS (Handle, ex);
+                Raise ();
+                return ret;
+            }
+        }
+
+        /**
+         * Whether a video track is currently active.
+         * This is false if there is no video track, or if video is discarded.
+         */
+        public bool HasVideo
+        {
+            get
+            {
+                int ret = LibVLC.PlayerHasVout (Handle, ex);
+                Raise ();
+                return ret != 0;
+            }
+        }
+
+        /**
+         * Whether the media supports seeking.
+         * Note that this tells nothing about the seeking precision.
+         */
+        public bool CanSeek
+        {
+            get
+            {
+                int ret = LibVLC.PlayerIsSeekable (Handle, ex);
+                Raise ();
+                return ret != 0;
+            }
+        }
+
+        /**
+         * Whether the media supports pausing.
+         * Live content cannot be paused, unless timeshifting is enabled.
+         */
+        public bool CanPause
+        {
+            get
+            {
+                int ret = LibVLC.PlayerCanPause (Handle, ex);
+                Raise ();
+                return ret != 0;
+            }
+        }
     };
 };