summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVal Doroshchuk <valentyn.doroshchuk@qt.io>2020-04-30 11:37:17 +0200
committerVal Doroshchuk <valentyn.doroshchuk@qt.io>2020-09-10 14:52:27 +0200
commitab57d0efd91542aa542e3204bc01f8c894181efa (patch)
tree1a9de87b38c655b49e6fb278d5890ea4289d4cb8
parentcdd87907722aff14c393dba02b7e43c924b60d06 (diff)
AVF: Set playback audio session category while playing
Since when the application is active and then moved into the background then audio can be played fine. But if the application is already in the background then it will not play the audio. Decided to set AVAudioSessionCategoryPlayback with AVAudioSessionCategoryOptionMixWithOthers to audio session, which leads to restart playing from the background. Fixes: QTBUG-69949 Change-Id: I18fb4904b0810b7dfb63585278edbb8ee2f02d05 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm
index 61a78ac03..95121f58a 100644
--- a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm
+++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm
@@ -176,6 +176,9 @@ static void *AVFMediaPlayerSessionObserverCurrentItemDurationObservationContext
[m_playerLayer release];
m_playerLayer = 0;
}
+#if defined(Q_OS_IOS)
+ [[AVAudioSession sharedInstance] setActive:NO error:nil];
+#endif
}
- (void) prepareToPlayAsset:(AVURLAsset *)asset
@@ -288,7 +291,10 @@ static void *AVFMediaPlayerSessionObserverCurrentItemDurationObservationContext
forKeyPath:AVF_CURRENT_ITEM_DURATION_KEY
options:0
context:AVFMediaPlayerSessionObserverCurrentItemDurationObservationContext];
-
+#if defined(Q_OS_IOS)
+ [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil];
+ [[AVAudioSession sharedInstance] setActive:YES error:nil];
+#endif
}
-(void) assetFailedToPrepareForPlayback:(NSError *)error