Skip to content
Snippets Groups Projects
Commit 42348d77 authored by Felix Paul Kühne's avatar Felix Paul Kühne
Browse files

macosx/playlist controller: implement playback controls

parent e619a9f9
No related branches found
No related tags found
No related merge requests found
......@@ -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
*/
@property (readonly) BOOL hasPreviousPlaylistItem;
/**
* indicates whether there is a next item in the list the user could move on to
*/
@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
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment