Commit e7d2299a authored by Felix Paul Kühne's avatar Felix Paul Kühne

Remote Playback: automatically start playing once we cached at least 10% of the announced file size

parent fac63600
......@@ -36,6 +36,9 @@
NSString *_filepath;
UInt64 _contentLength;
UInt64 _receivedContent;
#if TARGET_OS_TV
BOOL _playbackStarted;
#endif
}
@end
......@@ -424,7 +427,25 @@
_receivedContent += postDataChunk.length;
APLog(@"received %lli kB (%lli %%)", _receivedContent / 1024, ((_receivedContent * 100) / _contentLength));
long long percentage = ((_receivedContent * 100) / _contentLength);
APLog(@"received %lli kB (%lli %%)", _receivedContent / 1024, percentage);
#if TARGET_OS_TV
if (!_playbackStarted) {
if (percentage >= 10) {
_playbackStarted = YES;
APLog(@"Starting playback of %@", _filepath);
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:[NSURL fileURLWithPath:_filepath] successCallback:nil errorCallback:nil];
VLCFullscreenMovieTVViewController *moviewVC = [VLCFullscreenMovieTVViewController fullscreenMovieTVViewController];
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:moviewVC
animated:YES
completion:nil];
}
}
#endif
}
//-----------------------------------------------------------------
......
......@@ -225,6 +225,12 @@
- (void)moveFileFrom:(NSString *)filepath
{
/* update media library when file upload was completed */
VLCActivityManager *activityManager = [VLCActivityManager defaultManager];
[activityManager networkActivityStopped];
[activityManager activateIdleTimer];
#if TARGET_OS_IOS
NSString *fileName = [filepath lastPathComponent];
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *libraryPath = searchPaths[0];
......@@ -251,11 +257,6 @@
[fileManager removeItemAtPath:filepath error:nil];
}
/* update media library when file upload was completed */
VLCActivityManager *activityManager = [VLCActivityManager defaultManager];
[activityManager networkActivityStopped];
[activityManager activateIdleTimer];
#if TARGET_OS_IOS
[[VLCMediaFileDiscoverer sharedInstance] performSelectorOnMainThread:@selector(updateMediaList) withObject:nil waitUntilDone:NO];
#endif
}
......
......@@ -13,6 +13,7 @@
#import "VLCPlaybackInfoTVViewController.h"
#import "VLCPlaybackInfoTVAnimators.h"
#import "VLCIRTVTapGestureRecognizer.h"
#import "VLCHTTPUploaderController.h"
typedef NS_ENUM(NSInteger, VLCPlayerScanState)
{
......@@ -139,6 +140,12 @@ typedef NS_ENUM(NSInteger, VLCPlayerScanState)
[vpc stopPlayback];
[super viewWillDisappear:animated];
/* clean caches in case remote playback was used
* note that if we cancel before the upload is complete
* the cache won't be emptied, but on the next launch only (or if the system is under storage pressure)
*/
[[VLCHTTPUploaderController sharedInstance] cleanCache];
}
- (BOOL)canBecomeFirstResponder
......
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