My application has 2 views, and I want to play a background sound only on the main view of the app. So when the app launches, it should play the sound until the user quits the app or when the user goes to the second view in the app. The sound should be played again when the user returns to the main view. Currently, I am calling a sub function, which plays the sound in the ‘viewDidLoad’ function. But it plays music only when it launches for the first time. It stops when I quit the application but not playing the music when I open the application again.
Share
try using the following methods
Notifies the view controller that its view is about to be added to a view hierarchy.
Notifies the view controller that its view is about to be removed from a view hierarchy.