iOS SDK : playing music on the background and switching views

后端 未结 5 1441
北荒
北荒 2020-12-03 16:09

I am trying to play music in my application. The music works fine but after switching viewControllers and returning to the main menu, my music plays again! It means several

5条回答
  •  無奈伤痛
    2020-12-03 16:51

    Initialize your player in app delegate file and play your background music. Only set one variable in app delegate which checks music play true or false...and enjoy your app without restarting music......

    In your code you initialize you player in view did load and init method... that's why you music restart.....just call it only once in app delegate applicationdidfinshLaunching() method....

提交回复
热议问题