VLCMediaPlayer.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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. VLCTime * cachedRemainingTime; //< Cached remaining time of the media being played
  79. VLCMediaPlayerState cachedState; //< Cached state of the media being played
  80. float position; //< The position of the media being played
  81. id drawable; //< The drawable associated to this media player
  82. }
  83. /* Initializers */
  84. - (id)initWithVideoView:(VLCVideoView *)aVideoView;
  85. - (id)initWithVideoLayer:(VLCVideoLayer *)aVideoLayer;
  86. /* Properties */
  87. - (void)setDelegate:(id)value;
  88. - (id)delegate;
  89. /* Video View Options */
  90. // TODO: Should be it's own object?
  91. - (void)setVideoView:(VLCVideoView *)aVideoView;
  92. - (void)setVideoLayer:(VLCVideoLayer *)aVideoLayer;
  93. @property (retain) id drawable; /* The videoView or videoLayer */
  94. - (void)setVideoAspectRatio:(char *)value;
  95. - (char *)videoAspectRatio;
  96. - (void)setVideoCropGeometry:(char *)value;
  97. - (char *)videoCropGeometry;
  98. /**
  99. * Take a snapshot of the current video.
  100. *
  101. * If width AND height is 0, original size is used.
  102. * If width OR height is 0, original aspect-ratio is preserved.
  103. *
  104. * \param path the path where to save the screenshot to
  105. * \param width the snapshot's width
  106. * \param height the snapshot's height
  107. */
  108. - (void)saveVideoSnapshotAt: (NSString *)path withWidth:(NSUInteger)width andHeight:(NSUInteger)height;
  109. /**
  110. * Enable or disable deinterlace filter
  111. *
  112. * \param name of deinterlace filter to use (availability depends on underlying VLC version)
  113. * \param enable boolean to enable or disable deinterlace filter
  114. */
  115. - (void)setDeinterlaceFilter: (NSString *)name enabled: (BOOL)enabled;
  116. @property float rate;
  117. @property (readonly) VLCAudio * audio;
  118. /* Video Information */
  119. - (NSSize)videoSize;
  120. - (BOOL)hasVideoOut;
  121. - (float)framesPerSecond;
  122. /**
  123. * Sets the current position (or time) of the feed.
  124. * \param value New time to set the current position to. If time is [VLCTime nullTime], 0 is assumed.
  125. */
  126. - (void)setTime:(VLCTime *)value;
  127. /**
  128. * Returns the current position (or time) of the feed.
  129. * \return VLCTIme object with current time.
  130. */
  131. - (VLCTime *)time;
  132. @property (readonly) VLCTime *remainingTime;
  133. @property (readonly) NSUInteger fps;
  134. /**
  135. * Return the current video subtitle index
  136. * \return 0 if none is set.
  137. *
  138. * Pass 0 to disable.
  139. */
  140. @property (readwrite) NSUInteger currentVideoSubTitleIndex;
  141. /**
  142. * Return the video subtitle tracks
  143. *
  144. * It includes the disabled fake track at index 0.
  145. */
  146. - (NSArray *)videoSubTitles;
  147. /**
  148. * Load and set a specific video subtitle, from a file.
  149. * \param path to a file
  150. * \return if the call succeed..
  151. */
  152. - (BOOL)openVideoSubTitlesFromFile:(NSString *)path;
  153. /**
  154. * Chapter selection and enumeration, it is bound
  155. * to a title option.
  156. */
  157. /**
  158. * Return the current video subtitle index, or
  159. * \return NSNotFound if none is set.
  160. *
  161. * To disable subtitle pass NSNotFound.
  162. */
  163. @property (readwrite) NSUInteger currentChapterIndex;
  164. - (void)previousChapter;
  165. - (void)nextChapter;
  166. - (NSArray *)chaptersForTitleIndex:(NSUInteger)titleIndex;
  167. /**
  168. * Title selection and enumeration
  169. * \return NSNotFound if none is set.
  170. */
  171. @property (readwrite) NSUInteger currentTitleIndex;
  172. - (NSArray *)titles;
  173. /* Audio Options */
  174. /**
  175. * Return the current audio track index
  176. * \return 0 if none is set.
  177. *
  178. * Pass 0 to disable.
  179. */
  180. @property (readwrite) NSUInteger currentAudioTrackIndex;
  181. /**
  182. * Return the audio tracks
  183. *
  184. * It includes the "Disable" fake track at index 0.
  185. */
  186. - (NSArray *)audioTracks;
  187. - (void)setAudioChannel:(NSInteger)value;
  188. - (NSInteger)audioChannel;
  189. /* Media Options */
  190. - (void)setMedia:(VLCMedia *)value;
  191. - (VLCMedia *)media;
  192. /* Playback Operations */
  193. /**
  194. * Plays a media resource using the currently selected media controller (or
  195. * default controller. If feed was paused then the feed resumes at the position
  196. * it was paused in.
  197. * \return A Boolean determining whether the stream was played or not.
  198. */
  199. - (BOOL)play;
  200. /**
  201. * Toggle's the pause state of the feed.
  202. */
  203. - (void)pause;
  204. /**
  205. * Stop the playing.
  206. */
  207. - (void)stop;
  208. /**
  209. * Advance one frame.
  210. */
  211. - (void)gotoNextFrame;
  212. /**
  213. * Fast forwards through the feed at the standard 1x rate.
  214. */
  215. - (void)fastForward;
  216. /**
  217. * Fast forwards through the feed at the rate specified.
  218. * \param rate Rate at which the feed should be fast forwarded.
  219. */
  220. - (void)fastForwardAtRate:(float)rate;
  221. /**
  222. * Rewinds through the feed at the standard 1x rate.
  223. */
  224. - (void)rewind;
  225. /**
  226. * Rewinds through the feed at the rate specified.
  227. * \param rate Rate at which the feed should be fast rewound.
  228. */
  229. - (void)rewindAtRate:(float)rate;
  230. /**
  231. * Jumps shortly backward in current stream if seeking is supported.
  232. * \param interval to skip, in sec.
  233. */
  234. - (void)jumpBackward:(NSInteger)interval;
  235. /**
  236. * Jumps shortly forward in current stream if seeking is supported.
  237. * \param interval to skip, in sec.
  238. */
  239. - (void)jumpForward:(NSInteger)interval;
  240. /**
  241. * Jumps shortly backward in current stream if seeking is supported.
  242. */
  243. - (void)extraShortJumpBackward;
  244. /**
  245. * Jumps shortly forward in current stream if seeking is supported.
  246. */
  247. - (void)extraShortJumpForward;
  248. /**
  249. * Jumps shortly backward in current stream if seeking is supported.
  250. */
  251. - (void)shortJumpBackward;
  252. /**
  253. * Jumps shortly forward in current stream if seeking is supported.
  254. */
  255. - (void)shortJumpForward;
  256. /**
  257. * Jumps shortly backward in current stream if seeking is supported.
  258. */
  259. - (void)mediumJumpBackward;
  260. /**
  261. * Jumps shortly forward in current stream if seeking is supported.
  262. */
  263. - (void)mediumJumpForward;
  264. /**
  265. * Jumps shortly backward in current stream if seeking is supported.
  266. */
  267. - (void)longJumpBackward;
  268. /**
  269. * Jumps shortly forward in current stream if seeking is supported.
  270. */
  271. - (void)longJumpForward;
  272. /* Playback Information */
  273. /**
  274. * Playback state flag identifying that the stream is currently playing.
  275. * \return TRUE if the feed is playing, FALSE if otherwise.
  276. */
  277. - (BOOL)isPlaying;
  278. /**
  279. * Playback state flag identifying wheather the stream will play.
  280. * \return TRUE if the feed is ready for playback, FALSE if otherwise.
  281. */
  282. - (BOOL)willPlay;
  283. /**
  284. * Playback's current state.
  285. * \see VLCMediaState
  286. */
  287. - (VLCMediaPlayerState)state;
  288. /**
  289. * Returns the receiver's position in the reading.
  290. * \return A number between 0 and 1. indicating the position
  291. */
  292. - (float)position;
  293. - (void)setPosition:(float)newPosition;
  294. - (BOOL)isSeekable;
  295. - (BOOL)canPause;
  296. @end