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 *****************************************************************************/
27 #import <Foundation/Foundation.h>
29 # import <CoreGraphics/CoreGraphics.h>
40 /* Notification Messages */
41 extern NSString * VLCMediaPlayerTimeChanged;
42 extern NSString * VLCMediaPlayerStateChanged;
45 * VLCMediaPlayerState describes the state of the media player.
47 typedef enum VLCMediaPlayerState
49 VLCMediaPlayerStateStopped, //< Player has stopped
50 VLCMediaPlayerStateOpening, //< Stream is opening
51 VLCMediaPlayerStateBuffering, //< Stream is buffering
52 VLCMediaPlayerStateEnded, //< Stream has ended
53 VLCMediaPlayerStateError, //< Player has generated an error
54 VLCMediaPlayerStatePlaying, //< Stream is playing
55 VLCMediaPlayerStatePaused //< Stream is paused
56 } VLCMediaPlayerState;
59 * Returns the name of the player state as a string.
60 * \param state The player state.
61 * \return A string containing the name of state. If state is not a valid state, returns nil.
63 extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
66 * Formal protocol declaration for playback delegates. Allows playback messages
67 * to be trapped by delegated objects.
69 @protocol VLCMediaPlayerDelegate
71 * Sent by the default notification center whenever the player's time has changed.
72 * \details Discussion The value of aNotification is always an VLCMediaPlayerTimeChanged notification. You can retrieve
73 * the VLCMediaPlayer object in question by sending object to aNotification.
75 - (void)mediaPlayerTimeChanged:(NSNotification *)aNotification;
78 * Sent by the default notification center whenever the player's state has changed.
79 * \details Discussion The value of aNotification is always an VLCMediaPlayerStateChanged notification. You can retrieve
80 * the VLCMediaPlayer object in question by sending object to aNotification.
82 - (void)mediaPlayerStateChanged:(NSNotification *)aNotification;
86 // TODO: Should we use medialist_player or our own flavor of media player?
87 @interface VLCMediaPlayer : NSObject
89 id delegate; //< Object delegate
90 void * instance; // Internal
91 VLCMedia * media; //< Current media being played
92 VLCTime * cachedTime; //< Cached time of the media being played
93 VLCTime * cachedRemainingTime; //< Cached remaining time of the media being played
94 VLCMediaPlayerState cachedState; //< Cached state of the media being played
95 float position; //< The position of the media being played
96 id drawable; //< The drawable associated to this media player
100 #if !TARGET_OS_IPHONE
102 - (id)initWithVideoView:(VLCVideoView *)aVideoView;
103 - (id)initWithVideoLayer:(VLCVideoLayer *)aVideoLayer;
107 - (void)setDelegate:(id)value;
110 /* Video View Options */
111 // TODO: Should be it's own object?
113 #if !TARGET_OS_IPHONE
114 - (void)setVideoView:(VLCVideoView *)aVideoView;
115 - (void)setVideoLayer:(VLCVideoLayer *)aVideoLayer;
118 @property (retain) id drawable; /* The videoView or videoLayer */
120 - (void)setVideoAspectRatio:(char *)value;
121 - (char *)videoAspectRatio;
123 - (void)setVideoCropGeometry:(char *)value;
124 - (char *)videoCropGeometry;
127 * Take a snapshot of the current video.
129 * If width AND height is 0, original size is used.
130 * If width OR height is 0, original aspect-ratio is preserved.
132 * \param path the path where to save the screenshot to
133 * \param width the snapshot's width
134 * \param height the snapshot's height
136 - (void)saveVideoSnapshotAt: (NSString *)path withWidth:(NSUInteger)width andHeight:(NSUInteger)height;
139 * Enable or disable deinterlace filter
141 * \param name of deinterlace filter to use (availability depends on underlying VLC version), NULL to disable.
143 - (void)setDeinterlaceFilter: (NSString *)name;
145 @property float rate;
147 @property (readonly) VLCAudio * audio;
149 /* Video Information */
152 - (float)framesPerSecond;
155 * Sets the current position (or time) of the feed.
156 * \param value New time to set the current position to. If time is [VLCTime nullTime], 0 is assumed.
158 - (void)setTime:(VLCTime *)value;
161 * Returns the current position (or time) of the feed.
162 * \return VLCTIme object with current time.
166 @property (readonly) VLCTime *remainingTime;
167 @property (readonly) NSUInteger fps;
170 * Return the current video subtitle index
171 * \return 0 if none is set.
175 @property (readwrite) NSUInteger currentVideoSubTitleIndex;
178 * Return the video subtitle tracks
180 * It includes the disabled fake track at index 0.
182 - (NSArray *)videoSubTitles;
185 * Load and set a specific video subtitle, from a file.
186 * \param path to a file
187 * \return if the call succeed..
189 - (BOOL)openVideoSubTitlesFromFile:(NSString *)path;
192 * Chapter selection and enumeration, it is bound
197 * Return the current video subtitle index, or
198 * \return NSNotFound if none is set.
200 * To disable subtitle pass NSNotFound.
202 @property (readwrite) NSUInteger currentChapterIndex;
203 - (void)previousChapter;
205 - (NSArray *)chaptersForTitleIndex:(NSUInteger)titleIndex;
208 * Title selection and enumeration
209 * \return NSNotFound if none is set.
211 @property (readwrite) NSUInteger currentTitleIndex;
217 * Return the current audio track index
218 * \return 0 if none is set.
222 @property (readwrite) NSUInteger currentAudioTrackIndex;
225 * Return the audio tracks
227 * It includes the "Disable" fake track at index 0.
229 - (NSArray *)audioTracks;
231 - (void)setAudioChannel:(NSInteger)value;
232 - (NSInteger)audioChannel;
235 - (void)setMedia:(VLCMedia *)value;
238 /* Playback Operations */
240 * Plays a media resource using the currently selected media controller (or
241 * default controller. If feed was paused then the feed resumes at the position
243 * \return A Boolean determining whether the stream was played or not.
248 * Toggle's the pause state of the feed.
260 - (void)gotoNextFrame;
263 * Fast forwards through the feed at the standard 1x rate.
268 * Fast forwards through the feed at the rate specified.
269 * \param rate Rate at which the feed should be fast forwarded.
271 - (void)fastForwardAtRate:(float)rate;
274 * Rewinds through the feed at the standard 1x rate.
279 * Rewinds through the feed at the rate specified.
280 * \param rate Rate at which the feed should be fast rewound.
282 - (void)rewindAtRate:(float)rate;
285 * Jumps shortly backward in current stream if seeking is supported.
286 * \param interval to skip, in sec.
288 - (void)jumpBackward:(NSInteger)interval;
291 * Jumps shortly forward in current stream if seeking is supported.
292 * \param interval to skip, in sec.
294 - (void)jumpForward:(NSInteger)interval;
297 * Jumps shortly backward in current stream if seeking is supported.
299 - (void)extraShortJumpBackward;
302 * Jumps shortly forward in current stream if seeking is supported.
304 - (void)extraShortJumpForward;
307 * Jumps shortly backward in current stream if seeking is supported.
309 - (void)shortJumpBackward;
312 * Jumps shortly forward in current stream if seeking is supported.
314 - (void)shortJumpForward;
317 * Jumps shortly backward in current stream if seeking is supported.
319 - (void)mediumJumpBackward;
322 * Jumps shortly forward in current stream if seeking is supported.
324 - (void)mediumJumpForward;
327 * Jumps shortly backward in current stream if seeking is supported.
329 - (void)longJumpBackward;
332 * Jumps shortly forward in current stream if seeking is supported.
334 - (void)longJumpForward;
336 /* Playback Information */
338 * Playback state flag identifying that the stream is currently playing.
339 * \return TRUE if the feed is playing, FALSE if otherwise.
344 * Playback state flag identifying wheather the stream will play.
345 * \return TRUE if the feed is ready for playback, FALSE if otherwise.
350 * Playback's current state.
353 - (VLCMediaPlayerState)state;
356 * Returns the receiver's position in the reading.
357 * \return A number between 0 and 1. indicating the position
360 - (void)setPosition:(float)newPosition;