Commit 85208872 authored by Carola Nitz's avatar Carola Nitz

MediaCategoryController: starting a file from a playlist or Album plays now the entire collection

parent 6a700de8
......@@ -10,6 +10,7 @@ import Foundation
class CollectionModel: MLBaseModel {
var sortModel: SortModel
var mediaCollection: MediaCollectionModel
typealias MLType = VLCMLMedia // could be anything
required init(medialibrary: MediaLibraryService) {
......@@ -18,6 +19,7 @@ class CollectionModel: MLBaseModel {
required init(mediaService: MediaLibraryService, mediaCollection: MediaCollectionModel) {
self.medialibrary = mediaService
self.mediaCollection = mediaCollection
files = mediaCollection.files()
sortModel = mediaCollection.sortModel() ?? SortModel([.default])
}
......
......@@ -362,7 +362,14 @@ extension VLCMediaCategoryViewController {
func play(media: VLCMLMedia) {
VLCPlaybackController.sharedInstance().fullscreenSessionRequested = media.subtype() != .albumTrack
VLCPlaybackController.sharedInstance().play(media)
if let collectionModel = model as? CollectionModel, collectionModel.mediaCollection is VLCMLPlaylist || collectionModel.mediaCollection is VLCMLAlbum {
guard let index = collectionModel.files.index(of: media) else {
return
}
VLCPlaybackController.sharedInstance().playMedia(at: index, fromCollection: collectionModel.files)
} else {
VLCPlaybackController.sharedInstance().play(media)
}
}
}
......
......@@ -17,5 +17,6 @@
@interface VLCPlaybackController (MediaLibrary)
- (void)playMediaLibraryObject:(NSManagedObject *)mediaObject;
- (void)playMedia:(VLCMLMedia *)media;
- (void)playMediaAtIndex:(NSInteger)index fromCollection:(NSArray<VLCMLMedia *> *)collection;
- (void)openMediaLibraryObject:(NSManagedObject *)mediaObject;
@end
......@@ -38,6 +38,11 @@
[self configureWithShowEpisode:(MLShowEpisode *)mediaObject];
}
- (void)playMediaAtIndex:(NSInteger)index fromCollection:(NSArray<VLCMLMedia *> *)collection
{
[self configureMediaListWithMLMedia:collection indexToPlay:(int) index];
}
- (void)playMedia:(VLCMLMedia *)media
{
[self configureMediaListWithMLMedia:@[media] indexToPlay:0];
......@@ -138,6 +143,7 @@ Open a file in the libraryViewController without changing the playstate
}
- (void)configureMediaListWithMLMedia:(NSArray<VLCMLMedia *> *)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) {
......
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