Commit e7125ebc authored by Felix Paul Kühne's avatar Felix Paul Kühne

server browsing: play folder contents as a playlist instead of individual items

Subtitles support missing so far
parent 06a74127
...@@ -20,8 +20,11 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -20,8 +20,11 @@ NS_ASSUME_NONNULL_BEGIN
@end @end
@interface VLCNetworkServerBrowserItemFTP : NSObject <VLCNetworkServerBrowserItem> @interface VLCNetworkServerBrowserItemFTP : NSObject <VLCNetworkServerBrowserItem>
- (instancetype)initWithDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL; - (instancetype)initWithDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL;
@property (nonatomic, readwrite) NSArray<id<VLCNetworkServerBrowserItem>> *items;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
@interface VLCNetworkServerBrowserFTP () <WRRequestDelegate> @interface VLCNetworkServerBrowserFTP () <WRRequestDelegate>
@property (nonatomic) NSURL *url; @property (nonatomic) NSURL *url;
@property (nonatomic) WRRequestListDirectory *FTPListDirRequest; @property (nonatomic) WRRequestListDirectory *FTPListDirRequest;
@property (nonatomic, readwrite) NSArray<id<VLCNetworkServerBrowserItem>> *items;
@end @end
...@@ -68,6 +67,20 @@ ...@@ -68,6 +67,20 @@
return self; return self;
} }
- (VLCMediaList *)mediaList
{
NSMutableArray *mediaArray = [NSMutableArray array];
@synchronized(_items) {
NSUInteger count = _items.count;
for (NSUInteger i = 0; i < count; i++) {
VLCMedia *media = [_items[i] media];
if (media)
[mediaArray addObject:media];
}
}
return [[VLCMediaList alloc] initWithArray:mediaArray];
}
#pragma mark - white raccoon delegation #pragma mark - white raccoon delegation
- (void)requestCompleted:(WRRequest *)request - (void)requestCompleted:(WRRequest *)request
...@@ -83,7 +96,9 @@ ...@@ -83,7 +96,9 @@
[filteredList addObject:[[VLCNetworkServerBrowserItemFTP alloc] initWithDictionary:dict baseURL:self.url]]; [filteredList addObject:[[VLCNetworkServerBrowserItemFTP alloc] initWithDictionary:dict baseURL:self.url]];
} }
[[NSOperationQueue mainQueue] addOperationWithBlock:^{ [[NSOperationQueue mainQueue] addOperationWithBlock:^{
self.items = [NSArray arrayWithArray:filteredList]; @synchronized(_items) {
_items = [NSArray arrayWithArray:filteredList];
}
[self.delegate networkServerBrowserDidUpdate:self]; [self.delegate networkServerBrowserDidUpdate:self];
}]; }];
} else } else
...@@ -132,4 +147,11 @@ ...@@ -132,4 +147,11 @@
return [[VLCNetworkServerBrowserFTP alloc] initWithURL:self.URL]; return [[VLCNetworkServerBrowserFTP alloc] initWithURL:self.URL];
} }
- (VLCMedia *)media
{
if (_URL)
return [VLCMedia mediaWithURL:_URL];
return nil;
}
@end @end
...@@ -46,10 +46,10 @@ ...@@ -46,10 +46,10 @@
for (NSUInteger i = 0; i < count; i++) { for (NSUInteger i = 0; i < count; i++) {
VLCMedia *media = [rootItems mediaAtIndex:i]; VLCMedia *media = [rootItems mediaAtIndex:i];
VLCMedia *newMedia = [VLCMedia mediaWithURL:media.url]; VLCMedia *newMedia = [VLCMedia mediaWithURL:media.url];
[self.mutableItems addObject:[[VLCNetworkServerBrowserItemVLCMedia alloc] initWithMedia:newMedia options:self.mediaOptions]];
newMedia.delegate = self; newMedia.delegate = self;
[newMedia addOptions:self.mediaOptions]; [newMedia addOptions:self.mediaOptions];
[newMedia parseWithOptions:VLCMediaParseNetwork]; [newMedia parseWithOptions:VLCMediaParseNetwork];
[self.mutableItems addObject:[[VLCNetworkServerBrowserItemVLCMedia alloc] initWithMedia:newMedia options:self.mediaOptions]];
} }
[rootItems unlock]; [rootItems unlock];
} }
...@@ -101,12 +101,11 @@ ...@@ -101,12 +101,11 @@
@end @end
@interface VLCNetworkServerBrowserItemVLCMedia () <VLCMediaDelegate> @interface VLCNetworkServerBrowserItemVLCMedia () <VLCMediaDelegate>
@property (nonatomic, readonly) VLCMedia *media;
@property (nonatomic, readonly) NSDictionary *mediaOptions; @property (nonatomic, readonly) NSDictionary *mediaOptions;
@end @end
@implementation VLCNetworkServerBrowserItemVLCMedia @implementation VLCNetworkServerBrowserItemVLCMedia
@synthesize name = _name, container = _container, fileSizeBytes = _fileSizeBytes, URL = _URL; @synthesize name = _name, container = _container, fileSizeBytes = _fileSizeBytes, URL = _URL, media = _media;
- (instancetype)initWithMedia:(VLCMedia *)media options:(NSDictionary *)mediaOptions; - (instancetype)initWithMedia:(VLCMedia *)media options:(NSDictionary *)mediaOptions;
{ {
......
...@@ -52,7 +52,9 @@ ...@@ -52,7 +52,9 @@
for (NSDictionary *dict in result) { for (NSDictionary *dict in result) {
[items addObject:[[VLCNetworkServerBrowserItemSharedLibrary alloc] initWithDictionary:dict]]; [items addObject:[[VLCNetworkServerBrowserItemSharedLibrary alloc] initWithDictionary:dict]];
} }
_items = [items copy]; @synchronized(_items) {
_items = [items copy];
}
[[NSOperationQueue mainQueue] addOperationWithBlock:^{ [[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self.delegate networkServerBrowserDidUpdate:self]; [self.delegate networkServerBrowserDidUpdate:self];
...@@ -60,6 +62,20 @@ ...@@ -60,6 +62,20 @@
}]; }];
} }
- (VLCMediaList *)mediaList
{
NSMutableArray *mediaArray = [NSMutableArray array];
@synchronized(_items) {
NSUInteger count = _items.count;
for (NSUInteger i = 0; i < count; i++) {
VLCMedia *media = [_items[i] media];
if (media)
[mediaArray addObject:media];
}
}
return [[VLCMediaList alloc] initWithArray:mediaArray];
}
@end @end
...@@ -90,4 +106,11 @@ ...@@ -90,4 +106,11 @@
return nil; return nil;
} }
- (VLCMedia *)media
{
if (!_URL)
return nil;
return [VLCMedia mediaWithURL:_URL];
}
@end @end
\ No newline at end of file
...@@ -95,12 +95,25 @@ ...@@ -95,12 +95,25 @@
self.title = titleValue; self.title = titleValue;
} }
self.plexAuthentification = newAuth; self.plexAuthentification = newAuth;
self.items = [newItems copy]; @synchronized(_items) {
_items = [newItems copy];
}
[[NSOperationQueue mainQueue] addOperationWithBlock:^{ [[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self.delegate networkServerBrowserDidUpdate:self]; [self.delegate networkServerBrowserDidUpdate:self];
}]; }];
} }
- (VLCMediaList *)mediaList
{
NSMutableArray *mediaArray = [NSMutableArray array];
@synchronized(_items) {
NSUInteger count = _items.count;
for (NSUInteger i = 0; i < count; i++) {
[mediaArray addObject:[_items[i] media]];
}
}
return [[VLCMediaList alloc] initWithArray:mediaArray];
}
- (NSString *)_urlAuth:(NSString *)url - (NSString *)_urlAuth:(NSString *)url
{ {
...@@ -168,6 +181,14 @@ ...@@ -168,6 +181,14 @@
return self; return self;
} }
- (VLCMedia *)media
{
if (!_URL)
return nil;
return [VLCMedia mediaWithURL:_URL];
}
- (id<VLCNetworkServerBrowser>)containerBrowser { - (id<VLCNetworkServerBrowser>)containerBrowser {
return [[VLCNetworkServerBrowserPlex alloc] initWithName:self.name url:self.URL auth:self.plexAuthentification]; return [[VLCNetworkServerBrowserPlex alloc] initWithName:self.name url:self.URL auth:self.plexAuthentification];
} }
......
...@@ -75,13 +75,29 @@ ...@@ -75,13 +75,29 @@
[itemsArray addObject:[[VLCNetworkServerBrowserItemUPnP alloc] initWithBasicObject:object device:self.upnpDevice]]; [itemsArray addObject:[[VLCNetworkServerBrowserItemUPnP alloc] initWithBasicObject:object device:self.upnpDevice]];
} }
self.items = [itemsArray copy]; @synchronized(_items) {
_items = [itemsArray copy];
}
[[NSOperationQueue mainQueue] addOperationWithBlock:^{ [[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self.delegate networkServerBrowserDidUpdate:self]; [self.delegate networkServerBrowserDidUpdate:self];
}]; }];
}]; }];
} }
- (VLCMediaList *)mediaList
{
NSMutableArray *mediaArray = [NSMutableArray array];
@synchronized(_items) {
NSUInteger count = _items.count;
for (NSUInteger i = 0; i < count; i++) {
VLCMedia *media = [_items[i] media];
if (media)
[mediaArray addObject:media];
}
}
return [[VLCMediaList alloc] initWithArray:mediaArray];
}
@end @end
...@@ -268,6 +284,13 @@ ...@@ -268,6 +284,13 @@
return broadcastImage; return broadcastImage;
} }
- (VLCMedia *)media
{
if (!_URL)
return nil;
return [VLCMedia mediaWithURL:_URL];
}
@end @end
#pragma mark - Multi Ressource #pragma mark - Multi Ressource
...@@ -288,6 +311,21 @@ ...@@ -288,6 +311,21 @@
- (void) update { - (void) update {
[self.delegate networkServerBrowserDidUpdate:self]; [self.delegate networkServerBrowserDidUpdate:self];
} }
- (VLCMediaList *)mediaList
{
NSMutableArray *mediaArray = [NSMutableArray array];
@synchronized(_items) {
NSUInteger count = _items.count;
for (NSUInteger i = 0; i < count; i++) {
VLCMedia *media = [_items[i] media];
if (media)
[mediaArray addObject:media];
}
}
return [[VLCMediaList alloc] initWithArray:mediaArray];
}
@end @end
...@@ -310,4 +348,11 @@ ...@@ -310,4 +348,11 @@
return nil; return nil;
} }
- (VLCMedia *)media
{
if (!_URL)
return nil;
return [VLCMedia mediaWithURL:_URL];
}
@end @end
...@@ -19,8 +19,10 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -19,8 +19,10 @@ NS_ASSUME_NONNULL_BEGIN
@protocol VLCNetworkServerBrowser <NSObject> @protocol VLCNetworkServerBrowser <NSObject>
@required
@property (nonatomic, weak) id <VLCNetworkServerBrowserDelegate> delegate; @property (nonatomic, weak) id <VLCNetworkServerBrowserDelegate> delegate;
@property (nonatomic, readonly, nullable) NSString *title; @property (nonatomic, readonly, nullable) NSString *title;
@property (nonatomic, readonly, copy) VLCMediaList *mediaList;
@property (nonatomic, copy, readonly) NSArray<id<VLCNetworkServerBrowserItem>> *items; @property (nonatomic, copy, readonly) NSArray<id<VLCNetworkServerBrowserItem>> *items;
- (void)update; - (void)update;
...@@ -34,10 +36,12 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -34,10 +36,12 @@ NS_ASSUME_NONNULL_BEGIN
@protocol VLCNetworkServerBrowserItem <NSObject> @protocol VLCNetworkServerBrowserItem <NSObject>
@required
@property (nonatomic, readonly, getter=isContainer) BOOL container; @property (nonatomic, readonly, getter=isContainer) BOOL container;
// if item is container browser is the browser for the container // if item is container browser is the browser for the container
@property (nonatomic, readonly, nullable) id<VLCNetworkServerBrowser> containerBrowser; @property (nonatomic, readonly, nullable) id<VLCNetworkServerBrowser> containerBrowser;
@property (nonatomic, readonly, nullable) VLCMedia *media;
@property (nonatomic, readonly) NSString *name; @property (nonatomic, readonly) NSString *name;
@property (nonatomic, readonly, nullable) NSURL *URL; @property (nonatomic, readonly, nullable) NSURL *URL;
@property (nonatomic, readonly, nullable) NSNumber *fileSizeBytes; @property (nonatomic, readonly, nullable) NSNumber *fileSizeBytes;
......
...@@ -139,6 +139,12 @@ ...@@ -139,6 +139,12 @@
fileNameOfMedia:filename]; fileNameOfMedia:filename];
} }
- (void)_streamMediaList:(VLCMediaList *)mediaList startingAtIndex:(NSInteger)startIndex
{
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playMediaList:mediaList firstIndex:startIndex];
}
- (void)_streamFileForItem:(id<VLCNetworkServerBrowserItem>)item - (void)_streamFileForItem:(id<VLCNetworkServerBrowserItem>)item
{ {
NSString *URLofSubtitle = nil; NSString *URLofSubtitle = nil;
...@@ -311,10 +317,13 @@ ...@@ -311,10 +317,13 @@
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ {
id<VLCNetworkServerBrowserItem> item; id<VLCNetworkServerBrowserItem> item;
NSInteger row = indexPath.row;
BOOL searchResult = NO;
if (tableView == self.searchDisplayController.searchResultsTableView) { if (tableView == self.searchDisplayController.searchResultsTableView) {
item = _searchArray[indexPath.row]; item = _searchArray[row];
searchResult = YES;
} else { } else {
item = self.serverBrowser.items[indexPath.row]; item = self.serverBrowser.items[row];
} }
if (item.isContainer) { if (item.isContainer) {
...@@ -323,8 +332,13 @@ ...@@ -323,8 +332,13 @@
} else { } else {
if (![self isSupportedItem:item]) { if (![self isSupportedItem:item]) {
[self showUnsupportedFileAlertForItem:item]; [self showUnsupportedFileAlertForItem:item];
} else } else {
[self _streamFileForItem:item]; if (searchResult) {
[self _streamFileForItem:item];
} else {
[self _streamMediaList:self.serverBrowser.mediaList startingAtIndex:row];
}
}
} }
[tableView deselectRowAtIndexPath:indexPath animated:NO]; [tableView deselectRowAtIndexPath:indexPath animated:NO];
} }
......
...@@ -96,7 +96,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -96,7 +96,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
- (void)setNeedsMetadataUpdate; - (void)setNeedsMetadataUpdate;
- (void)scheduleSleepTimerWithInterval:(NSTimeInterval)timeInterval; - (void)scheduleSleepTimerWithInterval:(NSTimeInterval)timeInterval;
- (void)playMediaList:(VLCMediaList *)mediaList firstIndex:(int)index; - (void)playMediaList:(VLCMediaList *)mediaList firstIndex:(NSInteger)index;
- (void)playURL:(NSURL *)url successCallback:(NSURL*)successCallback errorCallback:(NSURL *)errorCallback; - (void)playURL:(NSURL *)url successCallback:(NSURL*)successCallback errorCallback:(NSURL *)errorCallback;
- (void)playURL:(NSURL *)url subtitlesFilePath:(NSString *)subsFilePath; - (void)playURL:(NSURL *)url subtitlesFilePath:(NSString *)subsFilePath;
- (void)remoteControlReceivedWithEvent:(UIEvent *)event; - (void)remoteControlReceivedWithEvent:(UIEvent *)event;
......
...@@ -142,10 +142,10 @@ NSString *const VLCPlaybackControllerPlaybackDidFail = @"VLCPlaybackControllerPl ...@@ -142,10 +142,10 @@ NSString *const VLCPlaybackControllerPlaybackDidFail = @"VLCPlaybackControllerPl
return YES; return YES;
} }
- (void)playMediaList:(VLCMediaList *)mediaList firstIndex:(int)index - (void)playMediaList:(VLCMediaList *)mediaList firstIndex:(NSInteger)index
{ {
self.mediaList = mediaList; self.mediaList = mediaList;
self.itemInMediaListToBePlayedFirst = index; self.itemInMediaListToBePlayedFirst = (int)index;
self.pathToExternalSubtitlesFile = nil; self.pathToExternalSubtitlesFile = nil;
if (self.activePlaybackSession) { if (self.activePlaybackSession) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment