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 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
91 - (id)initWithVideoView:(VLCVideoView *)aVideoView;
92 - (id)initWithVideoLayer:(VLCVideoLayer *)aVideoLayer;
95 - (void)setDelegate:(id)value;
98 /* Video View Options */
99 // TODO: Should be it's own object?
101 - (void)setVideoView:(VLCVideoView *)aVideoView;
102 - (void)setVideoLayer:(VLCVideoLayer *)aVideoLayer;
104 @property (retain) id drawable; /* The videoView or videoLayer */
106 - (void)setVideoAspectRatio:(char *)value;
107 - (char *)videoAspectRatio;
108 - (void)setVideoSubTitles:(int)value;
109 - (int)countOfVideoSubTitles;
110 - (int)currentVideoSubTitles;
111 - (BOOL)openVideoSubTitlesFromFile:(NSString *)path;
113 - (void)setVideoCropGeometry:(char *)value;
114 - (char *)videoCropGeometry;
116 - (void)setVideoTeleText:(int)value;
117 - (int)videoTeleText;
120 * Take a snapshot of the current video.
122 * If width AND height is 0, original size is used.
123 * If width OR height is 0, original aspect-ratio is preserved.
125 * \param path the path where to save the screenshot to
126 * \param width the snapshot's width
127 * \param height the snapshot's height
129 - (void)saveVideoSnapshotAt: (NSString *)path withWidth:(NSUInteger)width andHeight:(NSUInteger)height;
132 * Enable or disable deinterlace filter
134 * \param name of deinterlace filter to use (availability depends on underlying VLC version)
135 * \param enable boolean to enable or disable deinterlace filter
137 - (void)setDeinterlaceFilter: (NSString *)name enabled: (BOOL)enabled;
139 @property float rate;
141 @property (readonly) VLCAudio * audio;
143 /* Video Information */
146 - (float)framesPerSecond;
149 * Sets the current position (or time) of the feed.
150 * \param value New time to set the current position to. If time is [VLCTime nullTime], 0 is assumed.
152 - (void)setTime:(VLCTime *)value;
155 * Returns the current position (or time) of the feed.
156 * \return VLCTIme object with current time.
160 @property (readonly) VLCTime *remainingTime;
161 @property (readonly) int fps;
163 - (void)setChapter:(int)value;
164 - (int)currentChapter;
165 - (int)countOfChapters;
167 - (void)setCurrentTitle:(int)value;
169 - (int)countOfTitles;
172 - (void)setAudioTrack:(int)value;
173 - (int)currentAudioTrack;
174 - (int)countOfAudioTracks;
176 - (void)setAudioChannel:(int)value;
180 - (void)setMedia:(VLCMedia *)value;
183 /* Playback Operations */
185 * Plays a media resource using the currently selected media controller (or
186 * default controller. If feed was paused then the feed resumes at the position
188 * \return A Boolean determining whether the stream was played or not.
193 * Toggle's the pause state of the feed.
203 * Fast forwards through the feed at the standard 1x rate.
208 * Fast forwards through the feed at the rate specified.
209 * \param rate Rate at which the feed should be fast forwarded.
211 - (void)fastForwardAtRate:(float)rate;
214 * Rewinds through the feed at the standard 1x rate.
219 * Rewinds through the feed at the rate specified.
220 * \param rate Rate at which the feed should be fast rewound.
222 - (void)rewindAtRate:(float)rate;
225 * Jumps shortly backward in current stream if seeking is supported.
226 * \param interval to skip, in sec.
228 - (void)jumpBackward:(NSInteger)interval;
231 * Jumps shortly forward in current stream if seeking is supported.
232 * \param interval to skip, in sec.
234 - (void)jumpForward:(NSInteger)interval;
237 * Jumps shortly backward in current stream if seeking is supported.
239 - (void)extraShortJumpBackward;
242 * Jumps shortly forward in current stream if seeking is supported.
244 - (void)extraShortJumpForward;
247 * Jumps shortly backward in current stream if seeking is supported.
249 - (void)shortJumpBackward;
252 * Jumps shortly forward in current stream if seeking is supported.
254 - (void)shortJumpForward;
257 * Jumps shortly backward in current stream if seeking is supported.
259 - (void)mediumJumpBackward;
262 * Jumps shortly forward in current stream if seeking is supported.
264 - (void)mediumJumpForward;
267 * Jumps shortly backward in current stream if seeking is supported.
269 - (void)longJumpBackward;
272 * Jumps shortly forward in current stream if seeking is supported.
274 - (void)longJumpForward;
276 /* Playback Information */
278 * Playback state flag identifying that the stream is currently playing.
279 * \return TRUE if the feed is playing, FALSE if otherwise.
284 * Playback state flag identifying wheather the stream will play.
285 * \return TRUE if the feed is ready for playback, FALSE if otherwise.
290 * Playback's current state.
293 - (VLCMediaPlayerState)state;
296 * Returns the receiver's position in the reading.
297 * \return A number between 0 and 1. indicating the position
300 - (void)setPosition:(float)newPosition;