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

playback: retain last audio and subtitles tracks (close #8987)

Requires MediaLibraryKit 2.0.1
parent 909b44b8
......@@ -320,6 +320,11 @@
[_mediaPlayer play];
if (self.mediaItem.lastAudioTrack.intValue > 0)
_mediaPlayer.currentAudioTrackIndex = self.mediaItem.lastAudioTrack.intValue;
if (self.mediaItem.lastSubtitleTrack.intValue > 0)
_mediaPlayer.currentVideoSubTitleIndex = self.mediaItem.lastSubtitleTrack.intValue;
self.playbackSpeedSlider.value = [self _playbackSpeed];
[self _updatePlaybackSpeedIndicator];
......@@ -341,8 +346,7 @@
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
[_mediaPlayer pause];
[super viewWillDisappear:animated];
if (self.mediaItem)
self.mediaItem.lastPosition = @([_mediaPlayer position]);
[self _saveCurrentState];
[_mediaPlayer stop];
_mediaPlayer = nil; // save memory and some CPU time
......@@ -362,6 +366,15 @@
return self;
}
- (void)_saveCurrentState
{
if (self.mediaItem) {
self.mediaItem.lastPosition = @([_mediaPlayer position]);
self.mediaItem.lastAudioTrack = @(_mediaPlayer.currentAudioTrackIndex);
self.mediaItem.lastSubtitleTrack = @(_mediaPlayer.currentVideoSubTitleIndex);
}
}
#pragma mark - remote events
- (void)viewDidAppear:(BOOL)animated
......@@ -852,8 +865,7 @@
- (void)applicationWillResignActive:(NSNotification *)aNotification
{
if (self.mediaItem)
self.mediaItem.lastPosition = @([_mediaPlayer position]);
[self _saveCurrentState];
if (![[[NSUserDefaults standardUserDefaults] objectForKey:kVLCSettingContinueAudioInBackgroundKey] boolValue]) {
[_mediaPlayer pause];
......
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