本文共 2111 字,大约阅读时间需要 7 分钟。
原帖地址:http://www.cocoachina.com/bbs/read.php?tid=106913&page=1
用MPMoviePlayerController播放的网络上的音频。
想让程序在按了home键,切到后台以后,能继续播放音频,并且一个音频结束后,能再播放下一个~~ 现在,切换到后台后,正在播放的音频可以继续播放,没有问题; 但是,经Debug发现,当前的音频播放完了后,MPMoviePlayerPlaybackDid
申请后台任务:
两处关键代码:
第一个:xxxAppDelegate.m中
- (void)applicationDidEnterBackg
[application beginReceivingRemoteCont
第二个:播放器的play方法处
if([UIApplication sharedApplication].applicationState== UIApplicationStateBackgr
[_player play];
UIApplication*app = [UIApplication sharedApplication];
UIBackgroundTaskIdentifi
[app endBackgroundTask: bgTask];
} bgTask = newTask; } else {
[_player play];
}
以上!!
2. 锁屏状态下对播放器的控制
在你的xxxAppDelegate.m中,添加如下代码:
- (void)applicationDidEnterBackg
}
- (void)applicationWillEnterFore
}
- (void)remoteControlReceivedWit
if(event.type==
NSLog(@"Remote Control Type: %d", event.subtype);
switch
case
case
}
3. 锁屏状态下当前播放曲目的信息表示
- (void)configNowPlayingInfoCent
Class
NSDictionary*songInfo = [NSDictionary
}
转载地址:http://tseji.baihongyu.com/