VLCMediaPlayer.h 9.9 KB

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