vlc | branch: master | Felix Paul Kühne <[email protected]> | Thu Apr 11 18:35:29 2019 +0200| [45111cc13cc63a259e577328dca9771ff676f762] | committer: Felix Paul Kühne
macosx/playlist: expose export feature > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=45111cc13cc63a259e577328dca9771ff676f762 --- .../gui/macosx/playlist/VLCPlaylistController.h | 22 ++++++++++++ .../gui/macosx/playlist/VLCPlaylistController.m | 39 ++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/modules/gui/macosx/playlist/VLCPlaylistController.h b/modules/gui/macosx/playlist/VLCPlaylistController.h index 3b878ddec6..79b8b9e391 100644 --- a/modules/gui/macosx/playlist/VLCPlaylistController.h +++ b/modules/gui/macosx/playlist/VLCPlaylistController.h @@ -28,6 +28,7 @@ NS_ASSUME_NONNULL_BEGIN @class VLCPlaylistModel; @class VLCPlaylistDataSource; @class VLCPlayerController; +@class VLCPlaylistExportModuleDescription; extern NSString *VLCPlaybackOrderChanged; extern NSString *VLCPlaybackRepeatChanged; @@ -168,6 +169,27 @@ extern NSString *VLCPlaylistCurrentItemChanged; */ - (void)resumePlayback; +/** + * returns an array of module descriptions available for export a playlist. Content may vary + */ +@property (readonly) NSArray <VLCPlaylistExportModuleDescription *> *availablePlaylistExportModules; + +/** + * exports the playlist owned by the controller to a given file using the provided module + * @param path the file path to store the file in + * @param exportModule the VLCPlaylistExportModuleDescription for the respective export module + * @return VLC_SUCCESS or an error + */ +- (int)exportPlaylistToPath:(NSString *)path exportModule:(VLCPlaylistExportModuleDescription *)exportModule; + +@end + +@interface VLCPlaylistExportModuleDescription : NSObject + +@property (readwrite, retain) NSString *humanReadableName; +@property (readwrite, retain) NSString *fileExtension; +@property (readwrite, retain) NSString *moduleName; + @end NS_ASSUME_NONNULL_END diff --git a/modules/gui/macosx/playlist/VLCPlaylistController.m b/modules/gui/macosx/playlist/VLCPlaylistController.m index 887b761557..076bb6d39a 100644 --- a/modules/gui/macosx/playlist/VLCPlaylistController.m +++ b/modules/gui/macosx/playlist/VLCPlaylistController.m @@ -529,4 +529,43 @@ static const struct vlc_playlist_callbacks playlist_callbacks = { return p_input; } +- (NSArray<VLCPlaylistExportModuleDescription *> *)availablePlaylistExportModules +{ + VLCPlaylistExportModuleDescription *xspf = [[VLCPlaylistExportModuleDescription alloc] init]; + xspf.humanReadableName = _NS("XSPF playlist"); + xspf.fileExtension = @"xspf"; + xspf.moduleName = @"export-xspf"; + + VLCPlaylistExportModuleDescription *m3u = [[VLCPlaylistExportModuleDescription alloc] init]; + m3u.humanReadableName = _NS("M3U playlist"); + m3u.fileExtension = @"m3u"; + m3u.moduleName = @"export-m3u"; + + VLCPlaylistExportModuleDescription *m3u8 = [[VLCPlaylistExportModuleDescription alloc] init]; + m3u8.humanReadableName = _NS("M3U8 playlist"); + m3u8.fileExtension = @"m3u8"; + m3u8.moduleName = @"export-m3u8"; + + VLCPlaylistExportModuleDescription *html = [[VLCPlaylistExportModuleDescription alloc] init]; + html.humanReadableName = _NS("HTML playlist"); + html.fileExtension = @"html"; + html.moduleName = @"export-html"; + + return @[xspf, m3u, m3u8, html]; +} + +- (int)exportPlaylistToPath:(NSString *)path exportModule:(VLCPlaylistExportModuleDescription *)exportModule +{ + vlc_playlist_Lock(_p_playlist); + int ret = vlc_playlist_Export(_p_playlist, + path.fileSystemRepresentation, + exportModule.moduleName.UTF8String); + vlc_playlist_Unlock(_p_playlist); + return ret; +} + +@end + +@implementation VLCPlaylistExportModuleDescription + @end _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
