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
9 * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
10 * Felix Paul Kühne <fkuehne # videolan.org>
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.
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.
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 *****************************************************************************/
28 #import "VLCVideoView.h"
29 #import "VLCVideoLayer.h"
33 /* Notification Messages */
34 extern NSString * VLCMediaPlayerTimeChanged;
35 extern NSString * VLCMediaPlayerStateChanged;
38 * VLCMediaPlayerState describes the state of the media player.
40 typedef enum VLCMediaPlayerState
42 VLCMediaPlayerStateStopped, //< Player has stopped
43 VLCMediaPlayerStateOpening, //< Stream is opening
44 VLCMediaPlayerStateBuffering, //< Stream is buffering
45 VLCMediaPlayerStateEnded, //< Stream has ended
46 VLCMediaPlayerStateError, //< Player has generated an error
47 VLCMediaPlayerStatePlaying, //< Stream is playing
48 VLCMediaPlayerStatePaused //< Stream is paused
49 } VLCMediaPlayerState;
52 * Returns the name of the player state as a string.
53 * \param state The player state.
54 * \return A string containing the name of state. If state is not a valid state, returns nil.
56 extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
59 * Formal protocol declaration for playback delegates. Allows playback messages
60 * to be trapped by delegated objects.
62 @protocol VLCMediaPlayerDelegate
64 * Sent by the default notification center whenever the player's time has changed.
65 * \details Discussion The value of aNotification is always an VLCMediaPlayerTimeChanged notification. You can retrieve
66 * the VLCMediaPlayer object in question by sending object to aNotification.
68 - (void)mediaPlayerTimeChanged:(NSNotification *)aNotification;
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.
75 - (void)mediaPlayerStateChanged:(NSNotification *)aNotification;
78 // TODO: Should we use medialist_player or our own flavor of media player?
79 @interface VLCMediaPlayer : NSObject
81 id delegate; //< Object delegate
82 void * instance; // Internal
83 VLCMedia * media; //< Current media being played
84 VLCTime * cachedTime; //< Cached time of the media being played
85 VLCTime * cachedRemainingTime; //< Cached remaining time of the media being played
86 VLCMediaPlayerState cachedState; //< Cached state of the media being played
87 float position; //< The position of the media being played
88 id drawable; //< The drawable associated to this media player
92 - (id)initWithVideoView:(VLCVideoView *)aVideoView;
93 - (id)initWithVideoLayer:(VLCVideoLayer *)aVideoLayer;
96 - (void)setDelegate:(id)value;
99 /* Video View Options */
100 // TODO: Should be it's own object?
102 - (void)setVideoView:(VLCVideoView *)aVideoView;
103 - (void)setVideoLayer:(VLCVideoLayer *)aVideoLayer;
105 @property (retain) id drawable; /* The videoView or videoLayer */
107 - (void)setVideoAspectRatio:(char *)value;
108 - (char *)videoAspectRatio;
110 - (void)setVideoCropGeometry:(char *)value;
111 - (char *)videoCropGeometry;
113 - (void)setVideoTeleText:(int)value;
114 - (int)videoTeleText;
117 * Take a snapshot of the current video.
119 * If width AND height is 0, original size is used.
120 * If width OR height is 0, original aspect-ratio is preserved.
122 * \param path the path where to save the screenshot to
123 * \param width the snapshot's width
124 * \param height the snapshot's height
126 - (void)saveVideoSnapshotAt: (NSString *)path withWidth:(NSUInteger)width andHeight:(NSUInteger)height;
129 * Enable or disable deinterlace filter
131 * \param name of deinterlace filter to use (availability depends on underlying VLC version)
132 * \param enable boolean to enable or disable deinterlace filter
134 - (void)setDeinterlaceFilter: (NSString *)name enabled: (BOOL)enabled;
136 @property float rate;
138 @property (readonly) VLCAudio * audio;
140 /* Video Information */
143 - (float)framesPerSecond;
146 * Sets the current position (or time) of the feed.
147 * \param value New time to set the current position to. If time is [VLCTime nullTime], 0 is assumed.
149 - (void)setTime:(VLCTime *)value;
152 * Returns the current position (or time) of the feed.
153 * \return VLCTIme object with current time.
157 @property (readonly) VLCTime *remainingTime;
158 @property (readonly) int fps;
161 * Return the current video subtitle index
162 * \return 0 if none is set.
166 @property (readwrite) NSUInteger currentVideoSubTitleIndex;
169 * Return the video subtitle tracks
171 * It includes the disabled fake track at index 0.
173 - (NSArray *)videoSubTitles;
176 * Load and set a specific video subtitle, from a file.
177 * \param path to a file
178 * \return if the call succeed..
180 - (BOOL)openVideoSubTitlesFromFile:(NSString *)path;
183 * Chapter selection and enumeration, it is bound
188 * Return the current video subtitle index, or
189 * \return NSNotFound if none is set.
191 * To disable subtitle pass NSNotFound.
193 @property (readwrite) NSUInteger currentChapterIndex;
194 - (void)previousChapter;
196 - (NSArray *)chaptersForTitleIndex:(NSUInteger)titleIndex;
199 * Title selection and enumeration
200 * \return NSNotFound if none is set.
202 @property (readwrite) NSUInteger currentTitleIndex;
208 * Return the current audio track index
209 * \return 0 if none is set.
213 @property (readwrite) NSUInteger currentAudioTrackIndex;
216 * Return the audio tracks
218 * It includes the "Disable" fake track at index 0.
220 - (NSArray *)audioTracks;
222 - (void)setAudioChannel:(int)value;
226 - (void)setMedia:(VLCMedia *)value;
229 /* Playback Operations */
231 * Plays a media resource using the currently selected media controller (or
232 * default controller. If feed was paused then the feed resumes at the position
234 * \return A Boolean determining whether the stream was played or not.
239 * Toggle's the pause state of the feed.
249 * Fast forwards through the feed at the standard 1x rate.
254 * Fast forwards through the feed at the rate specified.
255 * \param rate Rate at which the feed should be fast forwarded.
257 - (void)fastForwardAtRate:(float)rate;
260 * Rewinds through the feed at the standard 1x rate.
265 * Rewinds through the feed at the rate specified.
266 * \param rate Rate at which the feed should be fast rewound.
268 - (void)rewindAtRate:(float)rate;
271 * Jumps shortly backward in current stream if seeking is supported.
272 * \param interval to skip, in sec.
274 - (void)jumpBackward:(NSInteger)interval;
277 * Jumps shortly forward in current stream if seeking is supported.
278 * \param interval to skip, in sec.
280 - (void)jumpForward:(NSInteger)interval;
283 * Jumps shortly backward in current stream if seeking is supported.
285 - (void)extraShortJumpBackward;
288 * Jumps shortly forward in current stream if seeking is supported.
290 - (void)extraShortJumpForward;
293 * Jumps shortly backward in current stream if seeking is supported.
295 - (void)shortJumpBackward;
298 * Jumps shortly forward in current stream if seeking is supported.
300 - (void)shortJumpForward;
303 * Jumps shortly backward in current stream if seeking is supported.
305 - (void)mediumJumpBackward;
308 * Jumps shortly forward in current stream if seeking is supported.
310 - (void)mediumJumpForward;
313 * Jumps shortly backward in current stream if seeking is supported.
315 - (void)longJumpBackward;
318 * Jumps shortly forward in current stream if seeking is supported.
320 - (void)longJumpForward;
322 /* Playback Information */
324 * Playback state flag identifying that the stream is currently playing.
325 * \return TRUE if the feed is playing, FALSE if otherwise.
330 * Playback state flag identifying wheather the stream will play.
331 * \return TRUE if the feed is ready for playback, FALSE if otherwise.
336 * Playback's current state.
339 - (VLCMediaPlayerState)state;
342 * Returns the receiver's position in the reading.
343 * \return A number between 0 and 1. indicating the position
346 - (void)setPosition:(float)newPosition;