我已尝试过此操作,但如果我开始使用新网址,则两个网址都会同时播放。
在PlayerViewController.h中
AVPlayer *radioPlayer;
在PlayerViewController.m中
- (void)Play_pressed{
NSURL * url = [NSURL URLWithString:@"http://listen.radionomy.com/radiomyme-tv"];
radioPlayer = [[AVPlayer alloc] initWithURL:url];
[radioPlayer play];}
- (void)Stop_pressed{
[radioPlayer pause];
[radioPlayer replaceCurrentItemWithPlayerItem:nil];
[radioPlayer pause];
radioPlayer = nil;}
答案 0 :(得分:0)
已解决!你只需要在Stop_pressed
中添加一行- (void)Stop_pressed{
[radioPlayer replaceCurrentItemWithPlayerItem:(nil)];
}