看板 MacDev 關於我們 聯絡資訊
NSError *activationErr = nil; NSError *setCategoryErr = nil; [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryErr]; [[AVAudioSession sharedInstance] setActive: YES error: &activationErr]; [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; self.moviePlayer.contentURL = videoURL; [self.moviePlayer play]; 上面的程式碼是放在viewDidLoad裏面 該viewController是繼承MPMoviePlayerViewController 所以self.moviePlayer是MPMoviePlayerController class 測試機器是iphone 5(ios 7.1) 雖然可以背景播放音樂 可是當按下home鍵進入背景模式後 音樂就立刻停止播放 必須在主畫面把下面的選單拉起來 再按下播放按鈕才會播放 想問的是為何我按下home鍵後 音樂為什麼會停止播放 不繼續播放 有人知道該如何讓app進入背景還會繼續播放音樂 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.130.235.117 ※ 文章網址: http://www.ptt.cc/bbs/MacDev/M.1397639632.A.005.html ※ 編輯: Cartel117 (220.130.235.117), 04/16/2014 17:24:34 ※ 編輯: Cartel117 (220.130.235.117), 04/16/2014 17:25:32
hakushadow:AudioSession那邊要記得設,另外Info.plist那邊 04/16 21:40
hakushadow:background_mode要包含音樂的選項 04/16 21:40
Cartel117:我有在Info.plist裡的Required background modes 04/17 09:41
Cartel117:App plays audio or streams audio/video using AirPlay 04/17 09:42
Cartel117:但是AudioSession要設什麼 可以告訴我該如何設定嗎 謝謝 04/17 09:43