]> git.sesse.net Git - vlc/blob - projects/macosx/framework/Headers/Public/VLCMediaPlayer.h
bbe0cbd81ab5f766558fa4e9ec383f893fbac9c3
[vlc] / projects / macosx / framework / Headers / Public / VLCMediaPlayer.h
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
27 #import "VLCMedia.h"
28 #import "VLCVideoView.h"
29 #import "VLCVideoLayer.h"
30 #import "VLCTime.h"
31 #import "VLCAudio.h"
32
33 /* Notification Messages */
34 extern NSString * VLCMediaPlayerTimeChanged;
35 extern NSString * VLCMediaPlayerStateChanged;
36
37 /**
38  * VLCMediaPlayerState describes the state of the media player.
39  */
40 typedef enum VLCMediaPlayerState
41 {
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;
50
51 /**
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.
55  */
56 extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
57
58 /**
59  * Formal protocol declaration for playback delegates.  Allows playback messages
60  * to be trapped by delegated objects.
61  */
62 @protocol VLCMediaPlayerDelegate
63 /**
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.
67  */
68 - (void)mediaPlayerTimeChanged:(NSNotification *)aNotification;
69
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
78 // TODO: Should we use medialist_player or our own flavor of media player?
79 @interface VLCMediaPlayer : NSObject
80 {
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
89 }
90
91 /* Initializers */
92 - (id)initWithVideoView:(VLCVideoView *)aVideoView;
93 - (id)initWithVideoLayer:(VLCVideoLayer *)aVideoLayer;
94
95 /* Properties */
96 - (void)setDelegate:(id)value;
97 - (id)delegate;
98
99 /* Video View Options */
100 // TODO: Should be it's own object?
101
102 - (void)setVideoView:(VLCVideoView *)aVideoView;
103 - (void)setVideoLayer:(VLCVideoLayer *)aVideoLayer;
104
105 @property (retain) id drawable; /* The videoView or videoLayer */
106
107 - (void)setVideoAspectRatio:(char *)value;
108 - (char *)videoAspectRatio;
109
110 - (void)setVideoCropGeometry:(char *)value;
111 - (char *)videoCropGeometry;
112
113 /**
114  * Take a snapshot of the current video.
115  *
116  * If width AND height is 0, original size is used.
117  * If width OR height is 0, original aspect-ratio is preserved.
118  *
119  * \param path the path where to save the screenshot to
120  * \param width the snapshot's width
121  * \param height the snapshot's height
122  */
123 - (void)saveVideoSnapshotAt: (NSString *)path withWidth:(NSUInteger)width andHeight:(NSUInteger)height;
124
125 /**
126  * Enable or disable deinterlace filter
127  *
128  * \param name of deinterlace filter to use (availability depends on underlying VLC version), NULL to disable.
129  */
130 - (void)setDeinterlaceFilter: (NSString *)name;
131
132 @property float rate;
133
134 @property (readonly) VLCAudio * audio;
135
136 /* Video Information */
137 - (NSSize)videoSize;
138 - (BOOL)hasVideoOut;
139 - (float)framesPerSecond;
140
141 /**
142  * Sets the current position (or time) of the feed.
143  * \param value New time to set the current position to.  If time is [VLCTime nullTime], 0 is assumed.
144  */
145 - (void)setTime:(VLCTime *)value;
146
147 /**
148  * Returns the current position (or time) of the feed.
149  * \return VLCTIme object with current time.
150  */
151 - (VLCTime *)time;
152
153 @property (readonly) VLCTime *remainingTime;
154 @property (readonly) NSUInteger fps;
155
156 /**
157  * Return the current video subtitle index
158  * \return 0 if none is set.
159  *
160  * Pass 0 to disable.
161  */
162 @property (readwrite) NSUInteger currentVideoSubTitleIndex;
163
164 /**
165  * Return the video subtitle tracks
166  *
167  * It includes the disabled fake track at index 0.
168  */
169 - (NSArray *)videoSubTitles;
170
171 /**
172  * Load and set a specific video subtitle, from a file.
173  * \param path to a file
174  * \return if the call succeed..
175  */
176 - (BOOL)openVideoSubTitlesFromFile:(NSString *)path;
177
178 /**
179  * Chapter selection and enumeration, it is bound
180  * to a title option.
181  */
182
183 /**
184  * Return the current video subtitle index, or
185  * \return NSNotFound if none is set.
186  *
187  * To disable subtitle pass NSNotFound.
188  */
189 @property (readwrite) NSUInteger currentChapterIndex;
190 - (void)previousChapter;
191 - (void)nextChapter;
192 - (NSArray *)chaptersForTitleIndex:(NSUInteger)titleIndex;
193
194 /**
195  * Title selection and enumeration
196  * \return NSNotFound if none is set.
197  */
198 @property (readwrite) NSUInteger currentTitleIndex;
199 - (NSArray *)titles;
200
201 /* Audio Options */
202
203 /**
204  * Return the current audio track index
205  * \return 0 if none is set.
206  *
207  * Pass 0 to disable.
208  */
209 @property (readwrite) NSUInteger currentAudioTrackIndex;
210
211 /**
212  * Return the audio tracks
213  *
214  * It includes the "Disable" fake track at index 0.
215  */
216 - (NSArray *)audioTracks;
217
218 - (void)setAudioChannel:(NSInteger)value;
219 - (NSInteger)audioChannel;
220
221 /* Media Options */
222 - (void)setMedia:(VLCMedia *)value;
223 - (VLCMedia *)media;
224
225 /* Playback Operations */
226 /**
227  * Plays a media resource using the currently selected media controller (or
228  * default controller.  If feed was paused then the feed resumes at the position
229  * it was paused in.
230  * \return A Boolean determining whether the stream was played or not.
231  */
232 - (BOOL)play;
233
234 /**
235  * Toggle's the pause state of the feed.
236  */
237 - (void)pause;
238
239 /**
240  * Stop the playing.
241  */
242 - (void)stop;
243
244 /**
245  * Advance one frame.
246  */
247 - (void)gotoNextFrame;
248
249 /**
250  * Fast forwards through the feed at the standard 1x rate.
251  */
252 - (void)fastForward;
253
254 /**
255  * Fast forwards through the feed at the rate specified.
256  * \param rate Rate at which the feed should be fast forwarded.
257  */
258 - (void)fastForwardAtRate:(float)rate;
259
260 /**
261  * Rewinds through the feed at the standard 1x rate.
262  */
263 - (void)rewind;
264
265 /**
266  * Rewinds through the feed at the rate specified.
267  * \param rate Rate at which the feed should be fast rewound.
268  */
269 - (void)rewindAtRate:(float)rate;
270
271 /**
272  * Jumps shortly backward in current stream if seeking is supported.
273  * \param interval to skip, in sec.
274  */
275 - (void)jumpBackward:(NSInteger)interval;
276
277 /**
278  * Jumps shortly forward in current stream if seeking is supported.
279  * \param interval to skip, in sec.
280  */
281 - (void)jumpForward:(NSInteger)interval;
282
283 /**
284  * Jumps shortly backward in current stream if seeking is supported.
285  */
286 - (void)extraShortJumpBackward;
287
288 /**
289  * Jumps shortly forward in current stream if seeking is supported.
290  */
291 - (void)extraShortJumpForward;
292
293 /**
294  * Jumps shortly backward in current stream if seeking is supported.
295  */
296 - (void)shortJumpBackward;
297
298 /**
299  * Jumps shortly forward in current stream if seeking is supported.
300  */
301 - (void)shortJumpForward;
302
303 /**
304  * Jumps shortly backward in current stream if seeking is supported.
305  */
306 - (void)mediumJumpBackward;
307
308 /**
309  * Jumps shortly forward in current stream if seeking is supported.
310  */
311 - (void)mediumJumpForward;
312
313 /**
314  * Jumps shortly backward in current stream if seeking is supported.
315  */
316 - (void)longJumpBackward;
317
318 /**
319  * Jumps shortly forward in current stream if seeking is supported.
320  */
321 - (void)longJumpForward;
322
323 /* Playback Information */
324 /**
325  * Playback state flag identifying that the stream is currently playing.
326  * \return TRUE if the feed is playing, FALSE if otherwise.
327  */
328 - (BOOL)isPlaying;
329
330 /**
331  * Playback state flag identifying wheather the stream will play.
332  * \return TRUE if the feed is ready for playback, FALSE if otherwise.
333  */
334 - (BOOL)willPlay;
335
336 /**
337  * Playback's current state.
338  * \see VLCMediaState
339  */
340 - (VLCMediaPlayerState)state;
341
342 /**
343  * Returns the receiver's position in the reading.
344  * \return A number between 0 and 1. indicating the position
345  */
346 - (float)position;
347 - (void)setPosition:(float)newPosition;
348
349 - (BOOL)isSeekable;
350
351 - (BOOL)canPause;
352
353 @end