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