Skip to content
  • Benjamin Adolphi's avatar
    Fixed finding of external subtitle files that are located on non libvlc browsed servers · 5088d8c1
    Benjamin Adolphi authored and Felix Paul Kühne's avatar Felix Paul Kühne committed
    
    
    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>
    5088d8c1