创建一个全局的avplayer

在viewcontroller中创建avplayer可能会导致再次进入viewcontroller的时候avplayer重复播放,为解决这个问题,可以在appDelegate中创建一个全局的avplayer,然后在viewcontroller中取得appDelegate的实例然后调用相关函数。

1
[(AppDelegate*)[[UIApplication sharedApplication]delegate]startPlayerWithURL:currentURL];