[vlc-commits] macosx/playlist controller: implement playback controls
Felix Paul Kühne
git at videolan.org
Thu Jan 31 16:10:33 CET 2019
vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Thu Jan 31 14:53:33 2019 +0100| [42348d7708c1fe8969988d7ca15126a8ab318e26] | committer: Felix Paul Kühne
macosx/playlist controller: implement playback controls
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=42348d7708c1fe8969988d7ca15126a8ab318e26
---
modules/gui/macosx/VLCPlaylistController.h | 87 ++++++++++++++++++++++++++----
modules/gui/macosx/VLCPlaylistController.m | 65 +++++++++++++++++++---
2 files changed, 137 insertions(+), 15 deletions(-)
diff --git a/modules/gui/macosx/VLCPlaylistController.h b/modules/gui/macosx/VLCPlaylistController.h
index 18b895db4c..a2fdd85966 100644
--- a/modules/gui/macosx/VLCPlaylistController.h
+++ b/modules/gui/macosx/VLCPlaylistController.h
@@ -30,31 +30,100 @@ NS_ASSUME_NONNULL_BEGIN
@interface VLCPlaylistController : NSObject
+/**
+ * The vlc core playlist controlled by the instance of this class
+ * @note You DO SOMETHING WRONG if you need to access this!
+ */
@property (readonly) vlc_playlist_t *p_playlist;
+
+/**
+ * The playlist model caching the contents of the playlist controlled by
+ * the instance of this class.
+ */
@property (readonly) VLCPlaylistModel *playlistModel;
+
+/**
+ * The datasource instance used to actually display the playlist.
+ */
@property (readwrite, assign) VLCPlaylistDataSource *playlistDataSource;
/**
- * Simplified version to add new items at the end of the current playlist
+ * indicates whether there is a previous item in the list the user could go back to
+ */
+ at property (readonly) BOOL hasPreviousPlaylistItem;
+
+/**
+ * indicates whether there is a next item in the list the user could move on to
+ */
+ at property (readonly) BOOL hasNextPlaylistItem;
+
+/**
+ * Simplified version to add new items to the end of the current playlist
* @param array array of items. Each item is a Dictionary with meta info.
*/
- (void)addPlaylistItems:(NSArray*)array;
/**
- * Adds new items to the playlist, at specified parent node and index.
- * @param o_array array of items. Each item is a Dictionary with meta info.
- * @param i_plItemId parent playlist node id, -1 for default playlist
- * @param i_position index for new items, -1 for appending at end
- * @param b_start starts playback of first item if true
+ * Add new items to the playlist, at specified index.
+ * @param itemArray array of items. Each item is a Dictionary with meta info.
+ * @param insertionIndex index for new items, -1 for appending at end
+ * @param startPlayback starts playback of first item if true
*/
- (void)addPlaylistItems:(NSArray*)itemArray
atPosition:(size_t)insertionIndex
- startPlayback:(BOOL)b_start;
-
-- (void)playItemAtIndex:(size_t)index;
+ startPlayback:(BOOL)startPlayback;
+/**
+ * Remove the item at the given index (if any)
+ * @param index the index to remove
+ */
- (void)removeItemAtIndex:(size_t)index;
+/**
+ * Clear the entire playlist
+ */
+- (void)clearPlaylist;
+
+/**
+ * Start the playlist
+ * @return Returns VLC_SUCCESS on success.
+ */
+- (int)startPlaylist;
+
+/**
+ * Play the previous item in the list (if any)
+ * @return Returns VLC_SUCCESS on success.
+ */
+- (int)playPreviousItem;
+
+/**
+ * Play the item at the given index (if any)
+ * @param index the index to play
+ * @return Returns VLC_SUCCESS on success.
+ */
+- (int)playItemAtIndex:(size_t)index;
+
+/**
+ * Play the previous item in the list (if any)
+ * @return Returns VLC_SUCCESS on success.
+ */
+- (int)playNextItem;
+
+/**
+ * Stop playback of the playlist and destroy all facilities
+ */
+- (void)stopPlayback;
+
+/**
+ * Pause playback of the playlist while keeping all facilities
+ */
+- (void)pausePlayback;
+
+/**
+ * Resume playback of the playlist if it was paused
+ */
+- (void)resumePlayback;
+
@end
NS_ASSUME_NONNULL_END
diff --git a/modules/gui/macosx/VLCPlaylistController.m b/modules/gui/macosx/VLCPlaylistController.m
index 30ea4e40cc..975108e88b 100644
--- a/modules/gui/macosx/VLCPlaylistController.m
+++ b/modules/gui/macosx/VLCPlaylistController.m
@@ -250,20 +250,73 @@ static const struct vlc_playlist_callbacks playlist_callbacks = {
}
}
-- (void)playItemAtIndex:(size_t)index
+- (void)removeItemAtIndex:(size_t)index
{
+ /* note: we don't remove the cached data from the model here
+ * because this will be done asynchronously through the callback */
+
vlc_playlist_Lock(_p_playlist);
- vlc_playlist_PlayAt(_p_playlist, index);
+ vlc_playlist_Remove(_p_playlist, index, 1);
vlc_playlist_Unlock(_p_playlist);
}
-- (void)removeItemAtIndex:(size_t)index
+- (void)clearPlaylist
{
- /* note: we don't remove the cached data from the model here
- * because this will be done asynchronously through the callback */
+ vlc_playlist_Lock(_p_playlist);
+ vlc_playlist_Clear(_p_playlist);
+ vlc_playlist_Unlock(_p_playlist);
+}
+- (int)startPlaylist
+{
vlc_playlist_Lock(_p_playlist);
- vlc_playlist_Remove(_p_playlist, index, 1);
+ int ret = vlc_playlist_Start(_p_playlist);
+ vlc_playlist_Unlock(_p_playlist);
+ return ret;
+}
+
+- (int)playPreviousItem
+{
+ vlc_playlist_Lock(_p_playlist);
+ int ret = vlc_playlist_Prev(_p_playlist);
+ vlc_playlist_Unlock(_p_playlist);
+ return ret;
+}
+
+- (int)playItemAtIndex:(size_t)index
+{
+ vlc_playlist_Lock(_p_playlist);
+ int ret = vlc_playlist_PlayAt(_p_playlist, index);
+ vlc_playlist_Unlock(_p_playlist);
+ return ret;
+}
+
+- (int)playNextItem
+{
+ vlc_playlist_Lock(_p_playlist);
+ int ret = vlc_playlist_Next(_p_playlist);
+ vlc_playlist_Unlock(_p_playlist);
+ return ret;
+}
+
+- (void)stopPlayback
+{
+ vlc_playlist_Lock(_p_playlist);
+ vlc_playlist_Stop(_p_playlist);
+ vlc_playlist_Unlock(_p_playlist);
+}
+
+- (void)pausePlayback
+{
+ vlc_playlist_Lock(_p_playlist);
+ vlc_playlist_Pause(_p_playlist);
+ vlc_playlist_Unlock(_p_playlist);
+}
+
+- (void)resumePlayback
+{
+ vlc_playlist_Lock(_p_playlist);
+ vlc_playlist_Resume(_p_playlist);
vlc_playlist_Unlock(_p_playlist);
}
More information about the vlc-commits
mailing list