Skip to content
  • Benjamin Adolphi's avatar
    Fixed bug where the VLCMedia server browser in some cases would play a folder instead of opening it · dd68214b
    Benjamin Adolphi authored and Felix Paul Kühne's avatar Felix Paul Kühne committed
    In some cases, when navigating through folders using the VLCMedia server browser, VLC would try to play the folder instead of listing its contents. One way to reproduce this is to browse the content of a folder, then go back the the parent folder, then browse the content of the same folder again and then browse the content of a sub-folder.
    
    The problem is in the _addMediaListRootItemsToList method of the VLCMedia server browser. This method makes a copy of the all the media in a folder. The copied media is then used to create VLCNetworkServerBrowserItemVLCMedia objects that are appended to the mutableItems list. When creating a new VLCNetworkServerBrowserItemVLCMedia, the initWithMedia:options: method decides whether the item is a folder or not based on the media type of the media. However, the copied media always has the 'VLCMediaTypeFile' type even when the media is a folder. This is because the input items of the original media objects are created in libvlc when the content of a folder is parsed and there, the type is set correctly. But when making a copy the way _addMediaListRootItemsToList does, libvlc will just set 'VLCMediaTypeFile' as the type of the input item of the media.
    
    This bug was actually mostly fixed by accident already (in f1bf1413
    
    ). In that commit, the original media is used to create the VLCNetworkServerBrowserItemVLCMedia objects instead of the copied one. Since the copying of media is not needed anymore, we can simply remove it completely and use the code from the accidential fix, which uses the original media.
    
    Signed-off-by: Felix Paul Kühne's avatarFelix Paul Kühne <fkuehne@videolan.org>
    dd68214b