Commit 1d66e600 authored by Felix Paul Kühne's avatar Felix Paul Kühne

VLC media server browser: fix behavior if parsing fails and add debug

parent 1d37786e
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#import "VLCNetworkServerBrowserVLCMedia.h" #import "VLCNetworkServerBrowserVLCMedia.h"
@interface VLCNetworkServerBrowserVLCMedia () <VLCMediaListDelegate> @interface VLCNetworkServerBrowserVLCMedia () <VLCMediaListDelegate, VLCMediaDelegate>
@property (nonatomic) VLCMedia *rootMedia; @property (nonatomic) VLCMedia *rootMedia;
@property (nonatomic) VLCMediaList *mediaList; @property (nonatomic) VLCMediaList *mediaList;
@property (nonatomic) NSMutableArray<id<VLCNetworkServerBrowserItem>> *mutableItems; @property (nonatomic) NSMutableArray<id<VLCNetworkServerBrowserItem>> *mutableItems;
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
if (self) { if (self) {
_mutableItems = [[NSMutableArray alloc] init]; _mutableItems = [[NSMutableArray alloc] init];
_rootMedia = media; _rootMedia = media;
_rootMedia.delegate = self;
[media parseWithOptions:VLCMediaParseNetwork]; [media parseWithOptions:VLCMediaParseNetwork];
_mediaList = [_rootMedia subitems]; _mediaList = [_rootMedia subitems];
_mediaList.delegate = self; _mediaList.delegate = self;
...@@ -35,8 +36,13 @@ ...@@ -35,8 +36,13 @@
} }
return self; return self;
} }
- (void)update { - (void)update {
[self.rootMedia parseWithOptions:VLCMediaParseNetwork]; int ret = [self.rootMedia parseWithOptions:VLCMediaParseNetwork | VLCMediaFetchNetwork];
APLog(@"%s: %i", __PRETTY_FUNCTION__, ret);
if (ret == -1) {
[self.delegate networkServerBrowserDidUpdate:self];
}
} }
- (NSString *)title { - (NSString *)title {
...@@ -51,6 +57,7 @@ ...@@ -51,6 +57,7 @@
- (void)mediaList:(VLCMediaList *)aMediaList mediaAdded:(VLCMedia *)media atIndex:(NSInteger)index - (void)mediaList:(VLCMediaList *)aMediaList mediaAdded:(VLCMedia *)media atIndex:(NSInteger)index
{ {
APLog(@"%s", __PRETTY_FUNCTION__);
[media parseWithOptions:VLCMediaParseNetwork]; [media parseWithOptions:VLCMediaParseNetwork];
[media addOptions:self.mediaOptions]; [media addOptions:self.mediaOptions];
[self.mutableItems addObject:[[VLCNetworkServerBrowserItemVLCMedia alloc] initWithMedia:media options:self.mediaOptions]]; [self.mutableItems addObject:[[VLCNetworkServerBrowserItemVLCMedia alloc] initWithMedia:media options:self.mediaOptions]];
...@@ -58,12 +65,26 @@ ...@@ -58,12 +65,26 @@
} }
- (void)mediaList:(VLCMediaList *)aMediaList mediaRemovedAtIndex:(NSInteger)index { - (void)mediaList:(VLCMediaList *)aMediaList mediaRemovedAtIndex:(NSInteger)index {
APLog(@"%s", __PRETTY_FUNCTION__);
[self.mutableItems removeObjectAtIndex:index]; [self.mutableItems removeObjectAtIndex:index];
[self.delegate networkServerBrowserDidUpdate:self]; [self.delegate networkServerBrowserDidUpdate:self];
} }
@end #pragma mark - media delegate
- (void)mediaDidFinishParsing:(VLCMedia *)aMedia
{
APLog(@"%s", __PRETTY_FUNCTION__);
[self.delegate networkServerBrowserDidUpdate:self];
}
- (void)mediaMetaDataDidChange:(VLCMedia *)aMedia
{
APLog(@"%s", __PRETTY_FUNCTION__);
[self.delegate networkServerBrowserDidUpdate:self];
}
@end
@interface VLCNetworkServerBrowserItemVLCMedia () @interface VLCNetworkServerBrowserItemVLCMedia ()
@property (nonatomic, readonly) VLCMedia *media; @property (nonatomic, readonly) VLCMedia *media;
...@@ -112,5 +133,3 @@ ...@@ -112,5 +133,3 @@
return [[self alloc] initWithMedia:media options:mediaOptions]; return [[self alloc] initWithMedia:media options:mediaOptions];
} }
@end @end
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