1 /*****************************************************************************
2 * VLCMediaPlayer.h: VLCKit.framework VLCMediaPlayer header
3 *****************************************************************************
4 * Copyright (C) 2007 Pierre d'Herbemont
5 * Copyright (C) 2007 the VideoLAN team
8 * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #import <Cocoa/Cocoa.h>
27 #import "VLCVideoView.h"
28 #import "VLCVideoLayer.h"
32 /* Notification Messages */
33 extern NSString * VLCMediaPlayerTimeChanged;
34 extern NSString * VLCMediaPlayerStateChanged;
37 * VLCMediaPlayerState describes the state of the media player.
39 typedef enum VLCMediaPlayerState
41 VLCMediaPlayerStateStopped, //< Player has stopped
42 VLCMediaPlayerStateOpening, //< Stream is opening
43 VLCMediaPlayerStateBuffering, //< Stream is buffering
44 VLCMediaPlayerStateEnded, //< Stream has ended
45 VLCMediaPlayerStateError, //< Player has generated an error
46 VLCMediaPlayerStatePlaying, //< Stream is playing
47 VLCMediaPlayerStatePaused //< Stream is paused
48 } VLCMediaPlayerState;
51 * Returns the name of the player state as a string.
52 * \param state The player state.
53 * \return A string containing the name of state. If state is not a valid state, returns nil.
55 extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
58 * Formal protocol declaration for playback delegates. Allows playback messages
59 * to be trapped by delegated objects.
61 @protocol VLCMediaPlayerDelegate
63 * Sent by the default notification center whenever the player's time has changed.
64 * \details Discussion The value of aNotification is always an VLCMediaPlayerTimeChanged notification. You can retrieve
65 * the VLCMediaPlayer object in question by sending object to aNotification.
67 - (void)mediaPlayerTimeChanged:(NSNotification *)aNotification;
70 * Sent by the default notification center whenever the player's state has changed.
71 * \details Discussion The value of aNotification is always an VLCMediaPlayerStateChanged notification. You can retrieve
72 * the VLCMediaPlayer object in question by sending object to aNotification.
74 - (void)mediaPlayerStateChanged:(NSNotification *)aNotification;
77 // TODO: Should we use medialist_player or our own flavor of media player?
78 @interface VLCMediaPlayer : NSObject
80 id delegate; //< Object delegate
81 void * instance; // Internal
82 VLCMedia * media; //< Current media being played
83 VLCTime * cachedTime; //< Cached time of the media being played
84 VLCMediaPlayerState cachedState; //< Cached state of the media being played
85 float position; //< The position of the media being played
86 id drawable; //< The drawable associated to this media player
90 - (id)initWithVideoView:(VLCVideoView *)aVideoView;
91 - (id)initWithVideoLayer:(VLCVideoLayer *)aVideoLayer;
94 - (void)setDelegate:(id)value;
97 /* Video View Options */
98 // TODO: Should be it's own object?
100 - (void)setVideoView:(VLCVideoView *)aVideoView;
101 - (void)setVideoLayer:(VLCVideoLayer *)aVideoLayer;
103 @property (retain) id drawable; /* The videoView or videoLayer */
105 - (void)setVideoAspectRatio:(char *)value;
106 - (char *)videoAspectRatio;
107 - (void)setVideoSubTitles:(int)value;
108 - (int)videoSubTitles;
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;
159 - (void)setChapter:(int)value;
161 - (int)countOfChapters;
164 - (void)setAudioTrack:(int)value;
166 - (int)countOfAudioTracks;
168 - (void)setAudioChannel:(int)value;
172 - (void)setMedia:(VLCMedia *)value;
175 /* Playback Operations */
177 * Plays a media resource using the currently selected media controller (or
178 * default controller. If feed was paused then the feed resumes at the position
180 * \return A Boolean determining whether the stream was played or not.
185 * Toggle's the pause state of the feed.
195 * Fast forwards through the feed at the standard 1x rate.
200 * Fast forwards through the feed at the rate specified.
201 * \param rate Rate at which the feed should be fast forwarded.
203 - (void)fastForwardAtRate:(float)rate;
206 * Rewinds through the feed at the standard 1x rate.
211 * Rewinds through the feed at the rate specified.
212 * \param rate Rate at which the feed should be fast rewound.
214 - (void)rewindAtRate:(float)rate;
217 * Jumps shortly backward in current stream if seeking is supported.
218 * \param interval to skip, in sec.
220 - (void)jumpBackward:(NSInteger)interval;
223 * Jumps shortly forward in current stream if seeking is supported.
224 * \param interval to skip, in sec.
226 - (void)jumpForward:(NSInteger)interval;
229 * Jumps shortly backward in current stream if seeking is supported.
231 - (void)extraShortJumpBackward;
234 * Jumps shortly forward in current stream if seeking is supported.
236 - (void)extraShortJumpForward;
239 * Jumps shortly backward in current stream if seeking is supported.
241 - (void)shortJumpBackward;
244 * Jumps shortly forward in current stream if seeking is supported.
246 - (void)shortJumpForward;
249 * Jumps shortly backward in current stream if seeking is supported.
251 - (void)mediumJumpBackward;
254 * Jumps shortly forward in current stream if seeking is supported.
256 - (void)mediumJumpForward;
259 * Jumps shortly backward in current stream if seeking is supported.
261 - (void)longJumpBackward;
264 * Jumps shortly forward in current stream if seeking is supported.
266 - (void)longJumpForward;
268 /* Playback Information */
270 * Playback state flag identifying that the stream is currently playing.
271 * \return TRUE if the feed is playing, FALSE if otherwise.
276 * Playback state flag identifying wheather the stream will play.
277 * \return TRUE if the feed is ready for playback, FALSE if otherwise.
282 * Playback's current state.
285 - (VLCMediaPlayerState)state;
288 * Returns the receiver's position in the reading.
289 * \return A number between 0 and 1. indicating the position
292 - (void)setPosition:(float)newPosition;