Commit 26264da5 authored by Carola Nitz's avatar Carola Nitz

VLCPlaybackController : remove playURL calls and use medialist instead everywhere

parent 0f8bdb39
Pipeline #217 failed with stage
in 0 seconds
...@@ -143,7 +143,11 @@ ...@@ -143,7 +143,11 @@
- (void)_openURLStringAndDismiss:(NSString *)urlString - (void)_openURLStringAndDismiss:(NSString *)urlString
{ {
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:[NSURL URLWithString:urlString] subtitlesFilePath:nil]; VLCMedia *media = [VLCMedia mediaWithURL:[NSURL URLWithString:urlString]];
VLCMediaList *medialist = [[VLCMediaList alloc] init];
[medialist addMedia:media];
[vpc playMediaList:medialist firstIndex:0 subtitlesFilePath:nil];
[self presentViewController:[VLCFullscreenMovieTVViewController fullscreenMovieTVViewController] [self presentViewController:[VLCFullscreenMovieTVViewController fullscreenMovieTVViewController]
animated:YES animated:YES
completion:nil]; completion:nil];
......
...@@ -268,12 +268,15 @@ ...@@ -268,12 +268,15 @@
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{ {
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
NSURL *url; NSURL *url;
@synchronized(_discoveredFiles) { @synchronized(_discoveredFiles) {
url = [NSURL fileURLWithPath:_discoveredFiles[indexPath.row]]; url = [NSURL fileURLWithPath:_discoveredFiles[indexPath.row]];
} }
[vpc playURL:url subtitlesFilePath:nil];
VLCMediaList *medialist = [[VLCMediaList alloc] init];
[medialist addMedia:[VLCMedia mediaWithURL:url]];
[[VLCPlaybackController sharedInstance] playMediaList:medialist firstIndex:0 subtitlesFilePath:nil];
[self presentViewController:[VLCFullscreenMovieTVViewController fullscreenMovieTVViewController] [self presentViewController:[VLCFullscreenMovieTVViewController fullscreenMovieTVViewController]
animated:YES animated:YES
completion:nil]; completion:nil];
......
...@@ -182,12 +182,14 @@ ...@@ -182,12 +182,14 @@
NSURL *url = service.directPlaybackURL; NSURL *url = service.directPlaybackURL;
if (!url) return; if (!url) return;
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCMediaList *medialist = [[VLCMediaList alloc] init];
[vpc playURL:url subtitlesFilePath:nil]; [medialist addMedia:[VLCMedia mediaWithURL:url]];
[[VLCPlaybackController sharedInstance] playMediaList:medialist firstIndex:0 subtitlesFilePath:nil];
[self presentViewController:[VLCFullscreenMovieTVViewController fullscreenMovieTVViewController] [self presentViewController:[VLCFullscreenMovieTVViewController fullscreenMovieTVViewController]
animated:YES animated:YES
completion:nil]; completion:nil];
return;
} }
} }
......
...@@ -164,8 +164,9 @@ ...@@ -164,8 +164,9 @@
[connection cancel]; [connection cancel];
/* now ask VLC to stream the URL we were just passed */ /* now ask VLC to stream the URL we were just passed */
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCMediaList *medialist = [[VLCMediaList alloc] init];
[vpc playURL:theActualURL successCallback:nil errorCallback:nil]; [medialist addMedia:[VLCMedia mediaWithURL:theActualURL]];
[[VLCPlaybackController sharedInstance] playMediaList:medialist firstIndex:0 subtitlesFilePath:nil];
VLCFullscreenMovieTVViewController *movieVC = [VLCFullscreenMovieTVViewController fullscreenMovieTVViewController]; VLCFullscreenMovieTVViewController *movieVC = [VLCFullscreenMovieTVViewController fullscreenMovieTVViewController];
[self presentViewController:movieVC [self presentViewController:movieVC
......
...@@ -96,8 +96,11 @@ ...@@ -96,8 +96,11 @@
} else { } else {
/* stream file */ /* stream file */
NSURL *url = [NSURL URLWithString:selectedObject.downloadPath]; NSURL *url = [NSURL URLWithString:selectedObject.downloadPath];
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:url successCallback:nil errorCallback:nil]; VLCMediaList *medialist = [[VLCMediaList alloc] init];
[medialist addMedia:[VLCMedia mediaWithURL:url]];
[[VLCPlaybackController sharedInstance] playMediaList:medialist firstIndex:0 subtitlesFilePath:nil];
VLCFullscreenMovieTVViewController *movieVC = [VLCFullscreenMovieTVViewController fullscreenMovieTVViewController]; VLCFullscreenMovieTVViewController *movieVC = [VLCFullscreenMovieTVViewController fullscreenMovieTVViewController];
[self presentViewController:movieVC [self presentViewController:movieVC
animated:YES animated:YES
......
...@@ -201,8 +201,7 @@ ...@@ -201,8 +201,7 @@
- (void)streamMediaList:(VLCMediaList *)mediaList startingAtIndex:(NSInteger)startIndex - (void)streamMediaList:(VLCMediaList *)mediaList startingAtIndex:(NSInteger)startIndex
{ {
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; [[VLCPlaybackController sharedInstance] playMediaList:mediaList firstIndex:startIndex subtitlesFilePath:nil];
[vpc playMediaList:mediaList firstIndex:startIndex];
[self showMovieViewController]; [self showMovieViewController];
} }
...@@ -221,10 +220,10 @@ ...@@ -221,10 +220,10 @@
if(remoteSubtitleURL) if(remoteSubtitleURL)
URLofSubtitle = [self _getFileSubtitleFromServer:remoteSubtitleURL]; URLofSubtitle = [self _getFileSubtitleFromServer:remoteSubtitleURL];
NSURL *URLToPlay = item.URL;
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:URLToPlay subtitlesFilePath:URLofSubtitle]; VLCMediaList *medialist = [[VLCMediaList alloc] init];
[medialist addMedia:[VLCMedia mediaWithURL:item.URL]];
[vpc playMediaList:medialist firstIndex:0 subtitlesFilePath:URLofSubtitle];
[self showMovieViewController]; [self showMovieViewController];
} }
......
...@@ -358,7 +358,7 @@ ...@@ -358,7 +358,7 @@
[mediaList addMedia:[VLCMedia mediaWithURL:[NSURL URLWithString:urlString]]]; [mediaList addMedia:[VLCMedia mediaWithURL:[NSURL URLWithString:urlString]]];
if (needsMediaList) { if (needsMediaList) {
[vpc playMediaList:mediaList firstIndex:0]; [vpc playMediaList:mediaList firstIndex:0 subtitlesFilePath:nil];
VLCFullscreenMovieTVViewController *movieVC = [VLCFullscreenMovieTVViewController fullscreenMovieTVViewController]; VLCFullscreenMovieTVViewController *movieVC = [VLCFullscreenMovieTVViewController fullscreenMovieTVViewController];
if ([[[UIApplication sharedApplication].delegate.window rootViewController] presentedViewController] != nil) { if ([[[UIApplication sharedApplication].delegate.window rootViewController] presentedViewController] != nil) {
......
...@@ -189,8 +189,10 @@ ...@@ -189,8 +189,10 @@
if ([service respondsToSelector:@selector(directPlaybackURL)]) { if ([service respondsToSelector:@selector(directPlaybackURL)]) {
NSURL *playbackURL = [service directPlaybackURL]; NSURL *playbackURL = [service directPlaybackURL];
if (playbackURL) { if (playbackURL) {
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:playbackURL successCallback:nil errorCallback:nil]; VLCMediaList *medialist = [[VLCMediaList alloc] init];
[medialist addMedia:[VLCMedia mediaWithURL:playbackURL]];
[[VLCPlaybackController sharedInstance] playMediaList:medialist firstIndex:0 subtitlesFilePath:nil];
return; return;
} }
} }
......
...@@ -340,7 +340,13 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType ...@@ -340,7 +340,13 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
if ([action isEqualToString:@"stream"] && movieURL) { if ([action isEqualToString:@"stream"] && movieURL) {
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
vpc.fullscreenSessionRequested = YES; vpc.fullscreenSessionRequested = YES;
[vpc playURL:movieURL successCallback:successCallback errorCallback:errorCallback];
VLCMediaList *medialist = [[VLCMediaList alloc] init];
[medialist addMedia:[VLCMedia mediaWithURL:movieURL]];
vpc.successCallback = successCallback;
vpc.errorCallback = errorCallback;
[vpc playMediaList:medialist firstIndex:0 subtitlesFilePath:nil];
} }
else if ([action isEqualToString:@"download"] && movieURL) { else if ([action isEqualToString:@"download"] && movieURL) {
[self downloadMovieFromURL:movieURL fileNameOfMedia:fileName]; [self downloadMovieFromURL:movieURL fileNameOfMedia:fileName];
...@@ -375,15 +381,19 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType ...@@ -375,15 +381,19 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
if (cancelled) if (cancelled)
[self downloadMovieFromURL:url fileNameOfMedia:nil]; [self downloadMovieFromURL:url fileNameOfMedia:nil];
else { else {
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCMedia *media = [VLCMedia mediaWithURL:url];
[vpc playURL:url successCallback:nil errorCallback:nil]; VLCMediaList *medialist = [[VLCMediaList alloc] init];
[medialist addMedia:media];
[[VLCPlaybackController sharedInstance] playMediaList:medialist firstIndex:0 subtitlesFilePath:nil];
} }
}; };
[alert show]; [alert show];
} else { } else {
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
vpc.fullscreenSessionRequested = YES; vpc.fullscreenSessionRequested = YES;
[vpc playURL:url successCallback:nil errorCallback:nil]; VLCMediaList *medialist = [[VLCMediaList alloc] init];
[medialist addMedia:[VLCMedia mediaWithURL:url]];
[vpc playMediaList:medialist firstIndex:0 subtitlesFilePath:nil];
} }
} }
return YES; return YES;
......
...@@ -221,7 +221,10 @@ ...@@ -221,7 +221,10 @@
/* now ask VLC to stream the URL we were just passed */ /* now ask VLC to stream the URL we were just passed */
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:theActualURL successCallback:nil errorCallback:nil]; VLCMedia *media = [VLCMedia mediaWithURL:theActualURL];
VLCMediaList *medialist = [[VLCMediaList alloc] init];
[medialist addMedia:media];
[[VLCPlaybackController sharedInstance] playMediaList:medialist firstIndex:0 subtitlesFilePath:nil];
} }
return request; return request;
......
...@@ -269,8 +269,10 @@ ...@@ -269,8 +269,10 @@
[[_client.filesRoutes getTemporaryLink:path] setResponseBlock:^(DBFILESGetTemporaryLinkResult * _Nullable result, DBFILESGetTemporaryLinkError * _Nullable routeError, DBRequestError * _Nullable networkError) { [[_client.filesRoutes getTemporaryLink:path] setResponseBlock:^(DBFILESGetTemporaryLinkResult * _Nullable result, DBFILESGetTemporaryLinkError * _Nullable routeError, DBRequestError * _Nullable networkError) {
if (result) { if (result) {
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCMedia *media = [VLCMedia mediaWithURL:[NSURL URLWithString:result.link]];
[vpc playURL:[NSURL URLWithString:result.link ] successCallback:nil errorCallback:nil]; VLCMediaList *medialist = [[VLCMediaList alloc] init];
[medialist addMedia:media];
[[VLCPlaybackController sharedInstance] playMediaList:medialist firstIndex:0 subtitlesFilePath:nil];
#if TARGET_OS_TV #if TARGET_OS_TV
if (_lastKnownNavigationController) { if (_lastKnownNavigationController) {
VLCFullscreenMovieTVViewController *movieVC = [VLCFullscreenMovieTVViewController fullscreenMovieTVViewController]; VLCFullscreenMovieTVViewController *movieVC = [VLCFullscreenMovieTVViewController fullscreenMovieTVViewController];
......
...@@ -219,7 +219,10 @@ ...@@ -219,7 +219,10 @@
file.identifier, token]; file.identifier, token];
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:[NSURL URLWithString:urlString] successCallback:nil errorCallback:nil]; VLCMedia *media = [VLCMedia mediaWithURL:[NSURL URLWithString:urlString]];
VLCMediaList *medialist = [[VLCMediaList alloc] init];
[medialist addMedia:media];
[vpc playMediaList:medialist firstIndex:0 subtitlesFilePath:nil];
} }
- (void)_triggerNextDownload - (void)_triggerNextDownload
......
...@@ -646,18 +646,16 @@ ...@@ -646,18 +646,16 @@
[_receivedFiles addObject:path]; [_receivedFiles addObject:path];
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
BOOL needsMediaList;
VLCMediaList *mediaList = vpc.mediaList; VLCMediaList *mediaList = vpc.mediaList;
if (!mediaList) { if (!mediaList) {
mediaList = [[VLCMediaList alloc] init]; mediaList = [[VLCMediaList alloc] init];
needsMediaList = YES;
} }
[mediaList addMedia:[VLCMedia mediaWithURL:[NSURL fileURLWithPath:path]]]; [mediaList addMedia:[VLCMedia mediaWithURL:[NSURL fileURLWithPath:path]]];
if (needsMediaList) { if (!vpc.mediaList) {
[vpc playMediaList:mediaList firstIndex:0]; [vpc playMediaList:mediaList firstIndex:0 subtitlesFilePath:nil];
} }
VLCFullscreenMovieTVViewController *movieVC = [VLCFullscreenMovieTVViewController fullscreenMovieTVViewController]; VLCFullscreenMovieTVViewController *movieVC = [VLCFullscreenMovieTVViewController fullscreenMovieTVViewController];
......
...@@ -113,7 +113,10 @@ ...@@ -113,7 +113,10 @@
NSString *subtitlePath = [self _searchSubtitle:selectedObject.name]; NSString *subtitlePath = [self _searchSubtitle:selectedObject.name];
subtitlePath = [self _getFileSubtitleFromServer:[NSURL URLWithString:subtitlePath]]; subtitlePath = [self _getFileSubtitleFromServer:[NSURL URLWithString:subtitlePath]];
NSURL *url = [NSURL URLWithString:selectedObject.downloadPath]; NSURL *url = [NSURL URLWithString:selectedObject.downloadPath];
[vpc playURL:url subtitlesFilePath:subtitlePath];
VLCMediaList *medialist = [[VLCMediaList alloc] init];
[medialist addMedia: [VLCMedia mediaWithURL:url]];
[[VLCPlaybackController sharedInstance] playMediaList:medialist firstIndex:0 subtitlesFilePath:subtitlePath];
} else { } else {
NSUInteger count = folderItems.count; NSUInteger count = folderItems.count;
NSMutableArray *mediaItems = [[NSMutableArray alloc] init]; NSMutableArray *mediaItems = [[NSMutableArray alloc] init];
...@@ -135,7 +138,7 @@ ...@@ -135,7 +138,7 @@
if (mediaItems.count > 0) { if (mediaItems.count > 0) {
firstIndex = mediaItems.count - posIndex; firstIndex = mediaItems.count - posIndex;
[vpc playMediaList:[[VLCMediaList alloc] initWithArray:mediaItems] firstIndex:firstIndex]; [vpc playMediaList:[[VLCMediaList alloc] initWithArray:mediaItems] firstIndex:firstIndex subtitlesFilePath:nil];
} }
} }
} }
...@@ -211,7 +214,7 @@ ...@@ -211,7 +214,7 @@
} }
if (mediaItems.count > 0) { if (mediaItems.count > 0) {
[vpc playMediaList:[[VLCMediaList alloc] initWithArray:mediaItems] firstIndex:0]; [vpc playMediaList:[[VLCMediaList alloc] initWithArray:mediaItems] firstIndex:0 subtitlesFilePath:nil];
} }
} }
......
...@@ -359,8 +359,10 @@ forRowAtIndexPath:(NSIndexPath *)indexPath ...@@ -359,8 +359,10 @@ forRowAtIndexPath:(NSIndexPath *)indexPath
URLofSubtitle = [self _checkURLofSubtitle:url]; URLofSubtitle = [self _checkURLofSubtitle:url];
} }
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCMedia *media = [VLCMedia mediaWithURL:[NSURL URLWithString:url]];
[vpc playURL:[NSURL URLWithString:url] subtitlesFilePath:URLofSubtitle]; VLCMediaList *medialist = [[VLCMediaList alloc] init];
[medialist addMedia:media];
[[VLCPlaybackController sharedInstance] playMediaList:medialist firstIndex:0 subtitlesFilePath:URLofSubtitle];
} }
- (NSString *)_checkURLofSubtitle:(NSString *)url - (NSString *)_checkURLofSubtitle:(NSString *)url
......
...@@ -132,8 +132,7 @@ Open a file in the libraryViewController without changing the playstate ...@@ -132,8 +132,7 @@ Open a file in the libraryViewController without changing the playstate
- (void)configureMediaList:(VLCMediaList *)list atIndex:(int)index - (void)configureMediaList:(VLCMediaList *)list atIndex:(int)index
{ {
self.pathToExternalSubtitlesFile = nil; [self playMediaList:list firstIndex:index subtitlesFilePath:nil];
[self playMediaList:list firstIndex:index];
} }
@end @end
...@@ -47,7 +47,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -47,7 +47,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
@property (nonatomic, readwrite) BOOL sessionWillRestart; @property (nonatomic, readwrite) BOOL sessionWillRestart;
@property (nonatomic, strong) NSURL *url;
@property (nonatomic, strong) NSURL *successCallback; @property (nonatomic, strong) NSURL *successCallback;
@property (nonatomic, strong) NSURL *errorCallback; @property (nonatomic, strong) NSURL *errorCallback;
...@@ -96,8 +95,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -96,8 +95,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
- (void)setNeedsMetadataUpdate; - (void)setNeedsMetadataUpdate;
- (void)scheduleSleepTimerWithInterval:(NSTimeInterval)timeInterval; - (void)scheduleSleepTimerWithInterval:(NSTimeInterval)timeInterval;
- (void)playMediaList:(VLCMediaList *)mediaList firstIndex:(NSInteger)index; - (void)playMediaList:(VLCMediaList *)mediaList firstIndex:(NSInteger)index subtitlesFilePath:(NSString *)subsFilePath;
- (void)playURL:(NSURL *)url successCallback:(NSURL*)successCallback errorCallback:(NSURL *)errorCallback;
- (void)playURL:(NSURL *)url subtitlesFilePath:(NSString *)subsFilePath;
@end @end
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
*****************************************************************************/ *****************************************************************************/
#import "VLCPlaybackController.h" #import "VLCPlaybackController.h"
#import <CommonCrypto/CommonDigest.h>
#import "UIDevice+VLC.h" #import "UIDevice+VLC.h"
#import <AVFoundation/AVFoundation.h> #import <AVFoundation/AVFoundation.h>
#import "VLCPlayerDisplayController.h" #import "VLCPlayerDisplayController.h"
...@@ -101,10 +100,13 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate> ...@@ -101,10 +100,13 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
{ {
self = [super init]; self = [super init];
if (self) { if (self) {
// listen to audiosessions and appkit callback
_headphonesWasPlugged = [self areHeadphonesPlugged]; _headphonesWasPlugged = [self areHeadphonesPlugged];
NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter]; NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
[defaultCenter addObserver:self selector:@selector(audioSessionRouteChange:) [defaultCenter addObserver:self selector:@selector(audioSessionRouteChange:)
name:AVAudioSessionRouteChangeNotification object:nil]; name:AVAudioSessionRouteChangeNotification object:nil];
// appkit because we neeed to know when we go to background in order to stop the video, so that we don't crash
[defaultCenter addObserver:self selector:@selector(applicationWillResignActive:) [defaultCenter addObserver:self selector:@selector(applicationWillResignActive:)
name:UIApplicationWillResignActiveNotification object:nil]; name:UIApplicationWillResignActiveNotification object:nil];
[defaultCenter addObserver:self selector:@selector(applicationDidBecomeActive:) [defaultCenter addObserver:self selector:@selector(applicationDidBecomeActive:)
...@@ -132,50 +134,14 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate> ...@@ -132,50 +134,14 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
} }
#pragma mark - playback management #pragma mark - playback management
- (void)playMediaList:(VLCMediaList *)mediaList firstIndex:(NSInteger)index - (void)playMediaList:(VLCMediaList *)mediaList firstIndex:(NSInteger)index subtitlesFilePath:(NSString *)subsFilePath
{ {
self.mediaList = mediaList; self.mediaList = mediaList;
self.itemInMediaListToBePlayedFirst = (int)index; self.itemInMediaListToBePlayedFirst = (int)index;
self.pathToExternalSubtitlesFile = nil;
if (self.activePlaybackSession) {
self.sessionWillRestart = YES;
[self stopPlayback];
} else {
self.sessionWillRestart = NO;
[self startPlayback];
}
}
- (void)playURL:(NSURL *)url successCallback:(NSURL*)successCallback errorCallback:(NSURL *)errorCallback
{
self.url = url;
self.successCallback = successCallback;
self.errorCallback = errorCallback;
if (self.activePlaybackSession) {
self.sessionWillRestart = YES;
[self stopPlayback];
} else {
self.sessionWillRestart = NO;
[self startPlayback];
}
}
- (void)playURL:(NSURL *)url subtitlesFilePath:(NSString *)subsFilePath
{
self.url = url;
self.pathToExternalSubtitlesFile = subsFilePath; self.pathToExternalSubtitlesFile = subsFilePath;
if (self.activePlaybackSession) { self.sessionWillRestart = self.activePlaybackSession;
self.sessionWillRestart = YES; self.activePlaybackSession ? [self stopPlayback] : [self startPlayback];
[self stopPlayback];
} else {
self.sessionWillRestart = NO;
dispatch_async(dispatch_get_main_queue(), ^{
[self startPlayback];
});
}
} }
- (void)startPlayback - (void)startPlayback
...@@ -199,7 +165,7 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate> ...@@ -199,7 +165,7 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if (!self.url && !self.mediaList) { if (!self.mediaList) {
APLog(@"%s: no URL and no media list set, stopping playback", __PRETTY_FUNCTION__); APLog(@"%s: no URL and no media list set, stopping playback", __PRETTY_FUNCTION__);
[_playbackSessionManagementLock unlock]; [_playbackSessionManagementLock unlock];
[self stopPlayback]; [self stopPlayback];
...@@ -234,23 +200,13 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate> ...@@ -234,23 +200,13 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
if (self.pathToExternalSubtitlesFile) if (self.pathToExternalSubtitlesFile)
[_mediaPlayer addPlaybackSlave:[NSURL fileURLWithPath:self.pathToExternalSubtitlesFile] type:VLCMediaPlaybackSlaveTypeSubtitle enforce:YES]; [_mediaPlayer addPlaybackSlave:[NSURL fileURLWithPath:self.pathToExternalSubtitlesFile] type:VLCMediaPlaybackSlaveTypeSubtitle enforce:YES];
VLCMedia *media; VLCMedia *media = [_mediaList mediaAtIndex:_itemInMediaListToBePlayedFirst];
if (_mediaList) { [media parseWithOptions:VLCMediaParseLocal];
media = [_mediaList mediaAtIndex:_itemInMediaListToBePlayedFirst]; media.delegate = self;
[media parseWithOptions:VLCMediaParseLocal]; [media addOptions:self.mediaOptionsDictionary];
media.delegate = self;
} else { [_listPlayer setMediaList:self.mediaList];
media = [VLCMedia mediaWithURL:self.url];
media.delegate = self;
[media parseWithOptions:VLCMediaParseLocal];
[media addOptions:self.mediaOptionsDictionary];
}
if (self.mediaList) {
[_listPlayer setMediaList:self.mediaList];
} else {
[_listPlayer setRootMedia:media];
}
[_listPlayer setRepeatMode:VLCDoNotRepeat]; [_listPlayer setRepeatMode:VLCDoNotRepeat];
[_playbackSessionManagementLock unlock]; [_playbackSessionManagementLock unlock];
...@@ -276,10 +232,7 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate> ...@@ -276,10 +232,7 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
[_mediaPlayer addObserver:self forKeyPath:@"time" options:0 context:nil]; [_mediaPlayer addObserver:self forKeyPath:@"time" options:0 context:nil];
[_mediaPlayer addObserver:self forKeyPath:@"remainingTime" options:0 context:nil]; [_mediaPlayer addObserver:self forKeyPath:@"remainingTime" options:0 context:nil];
if (self.mediaList) [_listPlayer playItemAtNumber:@(self.itemInMediaListToBePlayedFirst)];
[_listPlayer playItemAtNumber:@(self.itemInMediaListToBePlayedFirst)];
else
[_listPlayer playMedia:_listPlayer.rootMedia];
if ([self.delegate respondsToSelector:@selector(prepareForMediaPlayback:)]) if ([self.delegate respondsToSelector:@selector(prepareForMediaPlayback:)])
[self.delegate prepareForMediaPlayback:self]; [self.delegate prepareForMediaPlayback:self];
...@@ -320,16 +273,11 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate> ...@@ -320,16 +273,11 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
#endif #endif
[_mediaPlayer stop]; [_mediaPlayer stop];
} }
if (_mediaPlayer) _mediaPlayer = nil;
_mediaPlayer = nil; _listPlayer = nil;
if (_listPlayer)
_listPlayer = nil;
} }
if (!_sessionWillRestart) { if (!_sessionWillRestart) {
if (_mediaList) _mediaList = nil;
_mediaList = nil;
if (_url)
_url = nil;
if (_pathToExternalSubtitlesFile) { if (_pathToExternalSubtitlesFile) {
NSFileManager *fileManager = [NSFileManager defaultManager]; NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:_pathToExternalSubtitlesFile]) if ([fileManager fileExistsAtPath:_pathToExternalSubtitlesFile])
...@@ -340,10 +288,10 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate> ...@@ -340,10 +288,10 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
_playerIsSetup = NO; _playerIsSetup = NO;
[_shuffleStack removeAllObjects]; [_shuffleStack removeAllObjects];
if (self.errorCallback && _playbackFailed && !_sessionWillRestart) if (_errorCallback && _playbackFailed && !_sessionWillRestart)
[[UIApplication sharedApplication] openURL:self.errorCallback]; [[UIApplication sharedApplication] openURL:_errorCallback];
else if (self.successCallback && !_sessionWillRestart) else if (_successCallback && !_sessionWillRestart)
[[UIApplication sharedApplication] openURL:self.successCallback]; [[UIApplication sharedApplication] openURL:_successCallback];
[[self remoteControlService] unsubscribeFromRemoteCommands]; [[self remoteControlService] unsubscribeFromRemoteCommands];
_activeSession = NO; _activeSession = NO;
...@@ -369,10 +317,8 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate> ...@@ -369,10 +317,8 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
APLog(@"saving playback state failed"); APLog(@"saving playback state failed");
} }
MLFile *fileItem;
NSArray *files = [MLFile fileForURL:_mediaPlayer.media.url]; NSArray *files = [MLFile fileForURL:_mediaPlayer.media.url];
if (files.count > 0) MLFile *fileItem = files.firstObject;
fileItem = files.firstObject;
if (!fileItem) { if (!fileItem) {
APLog(@"couldn't find file, not saving playback progress"); APLog(@"couldn't find file, not saving playback progress");
...@@ -449,9 +395,8 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate> ...@@ -449,9 +395,8 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
_mediaWasJustStarted = NO; _mediaWasJustStarted = NO;
#if TARGET_OS_IOS #if TARGET_OS_IOS
if (self.mediaList) { if (self.mediaList) {
MLFile *item;
NSArray *matches = [MLFile fileForURL:_mediaPlayer.media.url]; NSArray *matches = [MLFile fileForURL:_mediaPlayer.media.url];
item = matches.firstObject; MLFile *item = matches.firstObject;
[self _recoverLastPlaybackStateOfItem:item]; [self _recoverLastPlaybackStateOfItem:item];
} }
#else #else
......
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