I am trying to play a url audio file picked with MPMediaPickerController
and attach an observer on the player
object. I don\'t know why the player is n
You should declare AVPlayer
as a global variable inside your class/struct. So, remove player
from addPeriodicTimeObserver
function and declare globally.
The reason behind this is:
Local variables (variables declared inside the function) get deallocated once the function returns; In this case, player
gets deallocated before even playing.
Instance variables (variables declared inside the class scope) get deallocated once the class instance get deallocated (unless there is a retain cycle).
In case of using a real device for testing, make sure that its not in silent mode