Finding subtitles in external subtitle files that are located on servers that are not browsed using libvlc is not working
I have been looking into an issue where when I play 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. I have been testing this mostly on tvOS but as far as I can see, this is also an issue on iOS.
The problem it seems is that when the user selects an item, the following code is executed in the 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, the mediaList is 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.
I think the simplest solution to this problem would be for the server browser classes that do not use libvlc to discover media to 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.
I would be happy to provide a patch for this but I was wondering if you think there is a better way to solve this issue?