2014-01-19 148 views
-1

如何讓我的應用程序在應用程序啓動後自動停止iPod音樂 - 如果正在播放? 我需要這個,所以當人們聽音樂並想要使用應用程序時,他們不需要在打開應用程序之前先暫停音樂。啓動應用程序時,iPod音樂應該停止播放

+0

只是猜測身邊:http://stackoverflow.com/questions/12475034/how-to-stop-and-resume-background-audio-from-iphone-app – plu

+0

很抱歉,如果我的問題不明確足夠。我正在爲Xcode開發iPhone應用程序,並希望該應用程序在啓動時暫停iPod音樂。不過謝謝你! – Kian

回答

3

足夠簡單,導入MediaPlayer框架並將iPodMusicPlayer指定爲stoppause

[[MPMusicPlayerController iPodMusicPlayer] stop]; 
[[MPMusicPlayerController iPodMusicPlayer] pause]; 
+0

還有一種方法可以避免讓應用程序突然暫停音樂,但可能會使其淡出。例如,youtube應用程序就是這樣。 – Kian

相關問題