Browse Source

playback: improve pausing when headphones are unplugged

(cherry picked from commit 131898e30af8e44a06f5065903c8b263a037076d)
Felix Paul Kühne 10 years ago
parent
commit
9acd094f76
1 changed files with 6 additions and 3 deletions
  1. 6 3
      Sources/VLCPlaybackController.m

+ 6 - 3
Sources/VLCPlaybackController.m

@@ -727,10 +727,13 @@ NSString *const VLCPlaybackControllerPlaybackDidFail = @"VLCPlaybackControllerPl
 - (void)audioSessionRouteChange:(NSNotification *)notification
 {
     NSArray *outputs = [[AVAudioSession sharedInstance] currentRoute].outputs;
-    NSString *portName = [[outputs objectAtIndex:0] portName];
+    NSString *portName = [[outputs firstObject] portName];
 
-    if (![portName isEqualToString:@"Headphones"] && [_mediaPlayer isPlaying])
-        [_listPlayer pause];
+    if (![portName isEqualToString:@"Headphones"] && [_mediaPlayer isPlaying]) {
+        [_mediaPlayer pause];
+        [self _savePlaybackState];
+        [[NSNotificationCenter defaultCenter] postNotificationName:VLCPlaybackControllerPlaybackDidPause object:self];
+    }
 }
 
 #pragma mark - Managing the media item