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