3 * @brief Media player class
6 * @defgroup API Managed interface to LibVLC
7 * This is the primary class library for .NET applications
8 * to embed and control LibVLC.
10 * @defgroup Internals LibVLC internals
11 * This covers internal marshalling functions to use the native LibVLC.
12 * Only VLC developpers should need to read this section.
15 /**********************************************************************
16 * Copyright (C) 2009 RĂ©mi Denis-Courmont. *
17 * This program is free software; you can redistribute and/or modify *
18 * it under the terms of the GNU General Public License as published *
19 * by the Free Software Foundation; version 2 of the license, or (at *
20 * your option) any later version. *
22 * This program is distributed in the hope that it will be useful, *
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
25 * See the GNU General Public License for more details. *
27 * You should have received a copy of the GNU General Public License *
28 * along with this program; if not, you can get it from: *
29 * http://www.gnu.org/copyleft/gpl.html *
30 **********************************************************************/
33 using System.Runtime.InteropServices;
35 namespace VideoLAN.LibVLC
38 * @brief PlayerHandle: unmanaged LibVLC media player pointer
41 internal sealed class PlayerHandle : NonNullHandle
43 protected override void Destroy ()
45 LibVLC.PlayerRelease (handle);
50 * @brief MediaPlayer: a simple media player
52 * Use this class to play a media.
54 public class Player : BaseObject
56 internal PlayerHandle Handle
60 return handle as PlayerHandle;
64 Media media; /**< Active media */
66 * The Media object that the MediaPlayer is using,
67 * or null if there is none.
77 MediaHandle mh = (value != null) ? value.Handle : null;
79 LibVLC.PlayerSetMedia (Handle, mh, null);
85 * Creates a player with no medias.
86 * An input media will be needed before this media player can be used.
88 * @param instance VLC instance
90 public Player (VLC instance)
93 handle = LibVLC.PlayerCreate (instance.Handle, ex);
98 * Creates a player object for a given a media.
100 * @param media media object
102 public Player (Media media)
105 handle = LibVLC.PlayerCreateFromMedia (media.Handle, ex);
110 * Whether the player is currently active.
112 public bool IsPlaying
116 int ret = LibVLC.PlayerIsPlaying (Handle, ex);
123 * Starts playing the selected media.
127 LibVLC.PlayerPlay (Handle, ex);
132 * Pauses the playback.
136 LibVLC.PlayerPause (Handle, ex);
141 * Stops the playback.
145 LibVLC.PlayerStop (Handle, ex);
150 * The 32-bits identifier of an X Window System window,
151 * or 0 if not specified.
152 * Video will be rendered inside that window, if the underlying VLC
153 * supports X11. Note that X pixmaps are <b>not</b> supported.
154 * Also note that you should set/change/unset the window while
155 * playback is not started or stopped; live reparenting might not
159 * If the identifier is invalid, Xlib might abort the process.
165 return LibVLC.PlayerGetXWindow (Handle);
169 LibVLC.PlayerSetXWindow (Handle, value, ex);
175 * The handle of a window (HWND) from the Win32 API,
176 * or NULL if unspecified.
177 * Video will be rendered inside that window, if the underlying VLC
178 * supports one of DirectDraw, Direct3D, GDI or OpenGL/Win32.
179 * Note that you should set/change/unset the window while playback is
180 * not started or stopped; live reparenting might not work.
182 public SafeHandle HWND
186 return LibVLC.PlayerGetHWND (Handle);
190 LibVLC.PlayerSetHWND (Handle, value, ex);
196 * Total length in milliseconds of the playback (if known).
202 long ret = LibVLC.PlayerGetLength (Handle, ex);
209 * Playback position in milliseconds from the start (if applicable).
210 * Setting this value might not work depending on the underlying
211 * media capability and file format.
213 * Changing the Time will also change the Position.
219 long ret = LibVLC.PlayerGetTime (Handle, ex);
225 LibVLC.PlayerSetTime (Handle, value, ex);
231 * Playback position as a fraction of the total (if applicable).
232 * At start, this is 0; at the end, this is 1.
233 * Setting this value might not work depending on the underlying
234 * media capability and file format.
236 * Changing the Position will also change the Time.
238 public float Position
242 float ret = LibVLC.PlayerGetPosition (Handle, ex);
248 LibVLC.PlayerSetPosition (Handle, value, ex);
254 * Number of the current chapter (within the current title).
255 * This is mostly used for DVDs and the likes.
261 int ret = LibVLC.PlayerGetChapter (Handle, ex);
267 LibVLC.PlayerSetChapter (Handle, value, ex);
273 * Number of chapters within the current title,
275 public int ChapterCount
279 int ret = LibVLC.PlayerGetChapterCount (Handle, ex);
286 * Gets the number of chapters within a given title.
287 * @param title media title number
289 public int GetChapterCountByTitle (int title)
291 int ret = LibVLC.PlayerGetChapterCountForTitle (Handle, title, ex);
297 * Number of the current title.
303 int ret = LibVLC.PlayerGetTitle (Handle, ex);
309 LibVLC.PlayerSetTitle (Handle, value, ex);
315 * Total number of titles.
317 public int TitleCount
321 int ret = LibVLC.PlayerGetTitleCount (Handle, ex);
328 * Skips to the beginning of the next chapter.
330 public void NextChapter ()
332 LibVLC.PlayerNextChapter (Handle, ex);
337 * Rewinds to the previous chapter.
339 public void PreviousChapter ()
341 LibVLC.PlayerPreviousChapter (Handle, ex);
346 * Media playback rate.
347 * 1.0 is the nominal rate.
348 * Less than one is slower than nominal.
349 * More than one is faster than nominal.
355 float ret = LibVLC.PlayerGetRate (Handle, ex);
361 LibVLC.PlayerSetRate (Handle, value, ex);
367 * Frame rate in unit/seconds.
369 public float FramePerSeconds
373 float ret = LibVLC.PlayerGetFPS (Handle, ex);
380 * Whether a video track is currently active.
381 * This is false if there is no video track, or if video is discarded.
387 int ret = LibVLC.PlayerHasVout (Handle, ex);
394 * Whether the media supports seeking.
395 * Note that this tells nothing about the seeking precision.
401 int ret = LibVLC.PlayerIsSeekable (Handle, ex);
408 * Whether the media supports pausing.
409 * Live content cannot be paused, unless timeshifting is enabled.
415 int ret = LibVLC.PlayerCanPause (Handle, ex);