Maxime Ghéraille
Maxime Ghéraille

Reputation: 1895

AVPlayer music stops when going to other view

im making a radio app and I have a swrevealviewcontroller with 3 views picture:

enter image description here

this is the code of my first view, in trying to play music from a link with AVPlayer. code:

I can start and stop the music from playing with this code but when I open the menu and click on a menulink my music stops playing.

I cannot find a solution for this, I have already added the bacground mode in capability.

btw every view controller already has one class assigned to it.

can somoene pls help me

Upvotes: 0

Views: 345

Answers (2)

Maxime Ghéraille
Maxime Ghéraille

Reputation: 1895

everything is working now by adding the player and the functions outside of the class, so now it's a global player with functions to start and play it

Upvotes: 0

R Bradshaw
R Bradshaw

Reputation: 183

Your AVPlayer variable is located within the class. So when you leave that viewcontroller - that variable no longer exists. Make it global (outside of the class) and that should work just fine.

Upvotes: 3

Related Questions