/***************************************************************************** * VLCPlaybackController+MediaLibrary.m * VLC for iOS ***************************************************************************** * Copyright (c) 2015-2019 VideoLAN. All rights reserved. * $Id$ * * Authors: Carola Nitz * Tobias Conradi * * Refer to the COPYING file of the official project for license. *****************************************************************************/ #import "VLCPlaybackController+MediaLibrary.h" #import #import @implementation VLCPlaybackController (MediaLibrary) - (void)playMediaAtIndex:(NSInteger)index fromCollection:(NSArray *)collection { [self configureMediaListWithMLMedia:collection indexToPlay:(int) index]; } - (void)playMedia:(VLCMLMedia *)media { [self configureMediaListWithMLMedia:@[media] indexToPlay:0]; } - (void)configureMediaListWithMLMedia:(NSArray *)mlMedia indexToPlay:(int)index { NSAssert(index >= 0, @"The index should never be negative"); VLCMediaList *list = [[VLCMediaList alloc] init]; VLCMedia *media; for (VLCMLMedia *file in mlMedia) { media = [VLCMedia mediaWithURL: file.mainFile.mrl]; [media addOptions:self.mediaOptionsDictionary]; [list addMedia:media]; } [self configureMediaList:list atIndex:index]; } - (void)configureMediaList:(VLCMediaList *)list atIndex:(int)index { [self playMediaList:list firstIndex:index subtitlesFilePath:nil]; } @end