Commit 5088d8c1 authored by Benjamin Adolphi's avatar Benjamin Adolphi Committed by Felix Paul Kühne

Fixed finding of external subtitle files that are located on non libvlc browsed servers

When playing a movie from a server on the local network that is not browsed with libvlc (e.g. an FTP server), subtitles that are located in an external file will not be discovered. This issue was observed on tvOS but should affect iOS as well.

The problem seems to be that when the user selects an item, the following code is executed in the VLCNetworkServerBrowserViewController/VLCServerBrowsingTVViewController (if not in single playback mode):

VLCMediaList *mediaList = self.serverBrowser.mediaList;
[self.browsingController configureSubtitlesInMediaList:mediaList];
[self.browsingController streamMediaList:mediaList startingAtIndex:index];

This code tries to find and configure the subtitles for all of the entries in the mediaList. However, at the time when configureSubtitlesInMediaList is called, the mediaList is always empty, so no subtitles are being configured.

The reason for the mediaList being empty is a timing issue. When the mediaList is retrieved from the responsible serverBrowser, it will create a new VLCMediaList from its items and add them to the list using the addMedia method. The problem here is that the addMedia method is adding the items to the list asynchronously on the main thread. Since the code that retrieves the list and then searches for the subtitles also runs on the main thread, the items will only be added after that code is finished.

This commit solves the problem by having the server browser classes that do not use libvlc to discover media not create the media list when the list is requested but already when the browser has found out which files are in the current location.
Signed-off-by: Felix Paul Kühne's avatarFelix Paul Kühne <fkuehne@videolan.org>
parent f623fe7f
......@@ -20,7 +20,7 @@
@end
@implementation VLCNetworkServerBrowserFTP
@synthesize delegate = _delegate, items = _items;
@synthesize delegate = _delegate, items = _items, mediaList = _mediaList;
#pragma mark - Protocol conformance
- (NSString *)title {
......@@ -75,7 +75,7 @@
return self;
}
- (VLCMediaList *)mediaList
- (VLCMediaList *)buildMediaList
{
VLCMediaList *mediaList = [[VLCMediaList alloc] init];
@synchronized(_items) {
......@@ -107,6 +107,7 @@
@synchronized(_items) {
_items = [NSArray arrayWithArray:filteredList];
}
_mediaList = [self buildMediaList];
[self.delegate networkServerBrowserDidUpdate:self];
}];
} else
......
......@@ -21,7 +21,7 @@
@end
@implementation VLCNetworkServerBrowserSharedLibrary
@synthesize title = _title, delegate = _delegate, items = _items;
@synthesize title = _title, delegate = _delegate, items = _items, mediaList = _mediaList;
- (instancetype)initWithName:(NSString *)name host:(NSString *)addressOrName portNumber:(NSUInteger)portNumber
{
......@@ -56,13 +56,14 @@
_items = [items copy];
}
_mediaList = [self buildMediaList];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self.delegate networkServerBrowserDidUpdate:self];
}];
}
- (VLCMediaList *)mediaList
- (VLCMediaList *)buildMediaList
{
VLCMediaList *mediaList = [[VLCMediaList alloc] init];
@synchronized(_items) {
......
......@@ -34,7 +34,7 @@
@end
@implementation VLCNetworkServerBrowserPlex
@synthesize title = _title, delegate = _delegate, items = _items;
@synthesize title = _title, delegate = _delegate, items = _items, mediaList = _mediaList;
- (instancetype)initWithLogin:(VLCNetworkServerLoginInformation *)login
{
......@@ -115,12 +115,13 @@
@synchronized(_items) {
_items = [newItems copy];
}
_mediaList = [self buildMediaList];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self.delegate networkServerBrowserDidUpdate:self];
}];
}
- (VLCMediaList *)mediaList
- (VLCMediaList *)buildMediaList
{
VLCMediaList *mediaList = [[VLCMediaList alloc] init];
@synchronized(_items) {
......
......@@ -28,7 +28,7 @@
@end
@implementation VLCNetworkServerBrowserUPnP
@synthesize title = _title, delegate = _delegate, items = _items;
@synthesize title = _title, delegate = _delegate, items = _items, mediaList = _mediaList;
- (instancetype)initWithUPNPDevice:(MediaServer1Device *)device header:(NSString *)header andRootID:(NSString *)upnpRootID
{
......@@ -78,13 +78,14 @@
@synchronized(_items) {
_items = [itemsArray copy];
}
_mediaList = [self buildMediaList];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self.delegate networkServerBrowserDidUpdate:self];
}];
}];
}
- (VLCMediaList *)mediaList
- (VLCMediaList *)buildMediaList
{
NSMutableArray *mediaArray;
@synchronized(_items) {
......@@ -319,7 +320,7 @@
#pragma mark - Multi Ressource
@implementation VLCNetworkServerBrowserUPnPMultiRessource
@synthesize items = _items, title = _title, delegate = _delegate;
@synthesize items = _items, title = _title, delegate = _delegate, mediaList = _mediaList;
- (instancetype)initWithItem:(MediaServer1ItemObject *)itemObject device:(MediaServer1Device *)device
{
......@@ -327,6 +328,7 @@
if (self) {
_title = [itemObject title];
_items = [itemObject vlc_ressourceItemsForDevice:device];
_mediaList = [self buildMediaList];
}
return self;
}
......@@ -335,7 +337,7 @@
[self.delegate networkServerBrowserDidUpdate:self];
}
- (VLCMediaList *)mediaList
- (VLCMediaList *)buildMediaList
{
VLCMediaList *mediaList = [[VLCMediaList alloc] init];
@synchronized(_items) {
......
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