[vlc-commits] macosx/playlist: add API to append items if we already have an input item
Felix Paul Kühne
git at videolan.org
Mon Apr 29 19:26:56 CEST 2019
vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sat Apr 27 17:09:40 2019 +0200| [7f9a2f8a848edb7c2fcf671387e4b193f89a4160] | committer: Felix Paul Kühne
macosx/playlist: add API to append items if we already have an input item
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7f9a2f8a848edb7c2fcf671387e4b193f89a4160
---
.../gui/macosx/playlist/VLCPlaylistController.h | 11 +++++++++++
.../gui/macosx/playlist/VLCPlaylistController.m | 23 ++++++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/modules/gui/macosx/playlist/VLCPlaylistController.h b/modules/gui/macosx/playlist/VLCPlaylistController.h
index cc5b4abf31..639e5f2459 100644
--- a/modules/gui/macosx/playlist/VLCPlaylistController.h
+++ b/modules/gui/macosx/playlist/VLCPlaylistController.h
@@ -121,6 +121,17 @@ extern NSString *VLCPlaylistItemsRemoved;
startPlayback:(BOOL)startPlayback;
/**
+ * Add new item to the playlist if you already have an input item
+ * @param p_inputItem the input item you already from somewhere
+ * @param insertionIndex index for new item, -1 for appending at end
+ * @param startPlayback starts playback of the item if true
+ * @return returns VLC_SUCCESS or an error
+ */
+- (int)addInputItem:(input_item_t *)p_inputItem
+ atPosition:(size_t)insertionIndex
+ startPlayback:(BOOL)startPlayback;
+
+/**
* Remove the item at the given index (if any)
* @param index the index to remove
*/
diff --git a/modules/gui/macosx/playlist/VLCPlaylistController.m b/modules/gui/macosx/playlist/VLCPlaylistController.m
index aea9cfeecb..49b05714da 100644
--- a/modules/gui/macosx/playlist/VLCPlaylistController.m
+++ b/modules/gui/macosx/playlist/VLCPlaylistController.m
@@ -363,6 +363,29 @@ static const struct vlc_playlist_callbacks playlist_callbacks = {
}
}
+- (int)addInputItem:(input_item_t *)p_inputItem atPosition:(size_t)insertionIndex startPlayback:(BOOL)startPlayback
+{
+ if (p_inputItem == NULL) {
+ return VLC_EBADVAR;
+ }
+ int ret = 0;
+
+ vlc_playlist_Lock(_p_playlist);
+ if (insertionIndex == -1) {
+ insertionIndex = vlc_playlist_Count(_p_playlist);
+ }
+ ret = vlc_playlist_InsertOne(_p_playlist, insertionIndex, p_inputItem);
+ if (ret != VLC_SUCCESS) {
+ vlc_playlist_Unlock(_p_playlist);
+ return ret;
+ }
+ if (startPlayback) {
+ ret = vlc_playlist_PlayAt(_p_playlist, insertionIndex);
+ }
+ vlc_playlist_Unlock(_p_playlist);
+ return ret;
+}
+
- (void)removeItemAtIndex:(size_t)index
{
/* note: we don't remove the cached data from the model here
More information about the vlc-commits
mailing list