VLCMediaPlayer.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. /*****************************************************************************
  2. * VLCMediaPlayer.h: VLCKit.framework VLCMediaPlayer header
  3. *****************************************************************************
  4. * Copyright (C) 2007-2009 Pierre d'Herbemont
  5. * Copyright (C) 2007-2009 the VideoLAN team
  6. * Partial Copyright (C) 2009 Felix Paul Kühne
  7. * $Id$
  8. *
  9. * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
  10. * Felix Paul Kühne <fkuehne # videolan.org>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  25. *****************************************************************************/
  26. #import "VLCMedia.h"
  27. #import "VLCVideoView.h"
  28. #import "VLCVideoLayer.h"
  29. #import "VLCTime.h"
  30. #import "VLCAudio.h"
  31. /* Notification Messages */
  32. extern NSString * VLCMediaPlayerTimeChanged;
  33. extern NSString * VLCMediaPlayerStateChanged;
  34. /**
  35. * VLCMediaPlayerState describes the state of the media player.
  36. */
  37. typedef enum VLCMediaPlayerState
  38. {
  39. VLCMediaPlayerStateStopped, //< Player has stopped
  40. VLCMediaPlayerStateOpening, //< Stream is opening
  41. VLCMediaPlayerStateBuffering, //< Stream is buffering
  42. VLCMediaPlayerStateEnded, //< Stream has ended
  43. VLCMediaPlayerStateError, //< Player has generated an error
  44. VLCMediaPlayerStatePlaying, //< Stream is playing
  45. VLCMediaPlayerStatePaused //< Stream is paused
  46. } VLCMediaPlayerState;
  47. /**
  48. * Returns the name of the player state as a string.
  49. * \param state The player state.
  50. * \return A string containing the name of state. If state is not a valid state, returns nil.
  51. */
  52. extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
  53. /**
  54. * Formal protocol declaration for playback delegates. Allows playback messages
  55. * to be trapped by delegated objects.
  56. */
  57. @protocol VLCMediaPlayerDelegate
  58. /**
  59. * Sent by the default notification center whenever the player's time has changed.
  60. * \details Discussion The value of aNotification is always an VLCMediaPlayerTimeChanged notification. You can retrieve
  61. * the VLCMediaPlayer object in question by sending object to aNotification.
  62. */
  63. - (void)mediaPlayerTimeChanged:(NSNotification *)aNotification;
  64. /**
  65. * Sent by the default notification center whenever the player's state has changed.
  66. * \details Discussion The value of aNotification is always an VLCMediaPlayerStateChanged notification. You can retrieve
  67. * the VLCMediaPlayer object in question by sending object to aNotification.
  68. */
  69. - (void)mediaPlayerStateChanged:(NSNotification *)aNotification;
  70. @end
  71. // TODO: Should we use medialist_player or our own flavor of media player?
  72. @interface VLCMediaPlayer : NSObject
  73. {
  74. id delegate; //< Object delegate
  75. void * instance; // Internal
  76. VLCMedia * media; //< Current media being played
  77. VLCTime * cachedTime; //< Cached time of the media being played
  78. VLCMediaPlayerState cachedState; //< Cached state of the media being played
  79. float position; //< The position of the media being played
  80. id drawable; //< The drawable associated to this media player
  81. }
  82. /* Initializers */
  83. - (id)initWithVideoView:(VLCVideoView *)aVideoView;
  84. - (id)initWithVideoLayer:(VLCVideoLayer *)aVideoLayer;
  85. /* Properties */
  86. - (void)setDelegate:(id)value;
  87. - (id)delegate;
  88. /* Video View Options */
  89. // TODO: Should be it's own object?
  90. - (void)setVideoView:(VLCVideoView *)aVideoView;
  91. - (void)setVideoLayer:(VLCVideoLayer *)aVideoLayer;
  92. @property (retain) id drawable; /* The videoView or videoLayer */
  93. - (void)setVideoAspectRatio:(char *)value;
  94. - (char *)videoAspectRatio;
  95. - (void)setVideoCropGeometry:(char *)value;
  96. - (char *)videoCropGeometry;
  97. - (void)setVideoTeleText:(int)value;
  98. - (int)videoTeleText;
  99. /**
  100. * Take a snapshot of the current video.
  101. *
  102. * If width AND height is 0, original size is used.
  103. * If width OR height is 0, original aspect-ratio is preserved.
  104. *
  105. * \param path the path where to save the screenshot to
  106. * \param width the snapshot's width
  107. * \param height the snapshot's height
  108. */
  109. - (void)saveVideoSnapshotAt: (NSString *)path withWidth:(NSUInteger)width andHeight:(NSUInteger)height;
  110. /**
  111. * Enable or disable deinterlace filter
  112. *
  113. * \param name of deinterlace filter to use (availability depends on underlying VLC version)
  114. * \param enable boolean to enable or disable deinterlace filter
  115. */
  116. - (void)setDeinterlaceFilter: (NSString *)name enabled: (BOOL)enabled;
  117. @property float rate;
  118. @property (readonly) VLCAudio * audio;
  119. /* Video Information */
  120. - (NSSize)videoSize;
  121. - (BOOL)hasVideoOut;
  122. - (float)framesPerSecond;
  123. /**
  124. * Sets the current position (or time) of the feed.
  125. * \param value New time to set the current position to. If time is [VLCTime nullTime], 0 is assumed.
  126. */
  127. - (void)setTime:(VLCTime *)value;
  128. /**
  129. * Returns the current position (or time) of the feed.
  130. * \return VLCTIme object with current time.
  131. */
  132. - (VLCTime *)time;
  133. @property (readonly) VLCTime *remainingTime;
  134. @property (readonly) int fps;
  135. /**
  136. * Return the current video subtitle index
  137. * \return 0 if none is set.
  138. *
  139. * Pass 0 to disable.
  140. */
  141. @property (readwrite) NSUInteger currentVideoSubTitleIndex;
  142. /**
  143. * Return the video subtitle tracks
  144. *
  145. * It includes the disabled fake track at index 0.
  146. */
  147. - (NSArray *)videoSubTitles;
  148. /**
  149. * Load and set a specific video subtitle, from a file.
  150. * \param path to a file
  151. * \return if the call succeed..
  152. */
  153. - (BOOL)openVideoSubTitlesFromFile:(NSString *)path;
  154. /**
  155. * Chapter selection and enumeration, it is bound
  156. * to a title option.
  157. */
  158. /**
  159. * Return the current video subtitle index, or
  160. * \return NSNotFound if none is set.
  161. *
  162. * To disable subtitle pass NSNotFound.
  163. */
  164. @property (readwrite) NSUInteger currentChapterIndex;
  165. - (void)previousChapter;
  166. - (void)nextChapter;
  167. - (NSArray *)chaptersForTitleIndex:(NSUInteger)titleIndex;
  168. /**
  169. * Title selection and enumeration
  170. * \return NSNotFound if none is set.
  171. */
  172. @property (readwrite) NSUInteger currentTitleIndex;
  173. - (NSArray *)titles;
  174. /* Audio Options */
  175. /**
  176. * Return the current audio track index
  177. * \return 0 if none is set.
  178. *
  179. * Pass 0 to disable.
  180. */
  181. @property (readwrite) NSUInteger currentAudioTrackIndex;
  182. /**
  183. * Return the audio tracks
  184. *
  185. * It includes the "Disable" fake track at index 0.
  186. */
  187. - (NSArray *)audioTracks;
  188. - (void)setAudioChannel:(int)value;
  189. - (int)audioChannel;
  190. /* Media Options */
  191. - (void)setMedia:(VLCMedia *)value;
  192. - (VLCMedia *)media;
  193. /* Playback Operations */
  194. /**
  195. * Plays a media resource using the currently selected media controller (or
  196. * default controller. If feed was paused then the feed resumes at the position
  197. * it was paused in.
  198. * \return A Boolean determining whether the stream was played or not.
  199. */
  200. - (BOOL)play;
  201. /**
  202. * Toggle's the pause state of the feed.
  203. */
  204. - (void)pause;
  205. /**
  206. * Stop the playing.
  207. */
  208. - (void)stop;
  209. /**
  210. * Fast forwards through the feed at the standard 1x rate.
  211. */
  212. - (void)fastForward;
  213. /**
  214. * Fast forwards through the feed at the rate specified.
  215. * \param rate Rate at which the feed should be fast forwarded.
  216. */
  217. - (void)fastForwardAtRate:(float)rate;
  218. /**
  219. * Rewinds through the feed at the standard 1x rate.
  220. */
  221. - (void)rewind;
  222. /**
  223. * Rewinds through the feed at the rate specified.
  224. * \param rate Rate at which the feed should be fast rewound.
  225. */
  226. - (void)rewindAtRate:(float)rate;
  227. /**
  228. * Jumps shortly backward in current stream if seeking is supported.
  229. * \param interval to skip, in sec.
  230. */
  231. - (void)jumpBackward:(NSInteger)interval;
  232. /**
  233. * Jumps shortly forward in current stream if seeking is supported.
  234. * \param interval to skip, in sec.
  235. */
  236. - (void)jumpForward:(NSInteger)interval;
  237. /**
  238. * Jumps shortly backward in current stream if seeking is supported.
  239. */
  240. - (void)extraShortJumpBackward;
  241. /**
  242. * Jumps shortly forward in current stream if seeking is supported.
  243. */
  244. - (void)extraShortJumpForward;
  245. /**
  246. * Jumps shortly backward in current stream if seeking is supported.
  247. */
  248. - (void)shortJumpBackward;
  249. /**
  250. * Jumps shortly forward in current stream if seeking is supported.
  251. */
  252. - (void)shortJumpForward;
  253. /**
  254. * Jumps shortly backward in current stream if seeking is supported.
  255. */
  256. - (void)mediumJumpBackward;
  257. /**
  258. * Jumps shortly forward in current stream if seeking is supported.
  259. */
  260. - (void)mediumJumpForward;
  261. /**
  262. * Jumps shortly backward in current stream if seeking is supported.
  263. */
  264. - (void)longJumpBackward;
  265. /**
  266. * Jumps shortly forward in current stream if seeking is supported.
  267. */
  268. - (void)longJumpForward;
  269. /* Playback Information */
  270. /**
  271. * Playback state flag identifying that the stream is currently playing.
  272. * \return TRUE if the feed is playing, FALSE if otherwise.
  273. */
  274. - (BOOL)isPlaying;
  275. /**
  276. * Playback state flag identifying wheather the stream will play.
  277. * \return TRUE if the feed is ready for playback, FALSE if otherwise.
  278. */
  279. - (BOOL)willPlay;
  280. /**
  281. * Playback's current state.
  282. * \see VLCMediaState
  283. */
  284. - (VLCMediaPlayerState)state;
  285. /**
  286. * Returns the receiver's position in the reading.
  287. * \return A number between 0 and 1. indicating the position
  288. */
  289. - (float)position;
  290. - (void)setPosition:(float)newPosition;
  291. - (BOOL)isSeekable;
  292. - (BOOL)canPause;
  293. @end