Xcode 停止AvPlayer并收听其他url

Xcode 停止AvPlayer并收听其他url,xcode,avplayer,Xcode,Avplayer,我已经试过了,但是如果我开始一个新的URL,两个URL将同时播放 在playervewcontroller.h中 AVPlayer *radioPlayer; 在playervewcontroller.m中 - (void)Play_pressed{ NSURL * url = [NSURL URLWithString:@"http://listen.radionomy.com/radiomyme-tv"]; radioPlayer = [[AV

我已经试过了,但是如果我开始一个新的URL,两个URL将同时播放

在playervewcontroller.h中

AVPlayer                         *radioPlayer;
在playervewcontroller.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;}

决心!只需在“停止”按钮中添加一行即可

- (void)Stop_pressed{
[radioPlayer replaceCurrentItemWithPlayerItem:(nil)];
}

决心!只需在“停止”按钮中添加一行即可

- (void)Stop_pressed{
[radioPlayer replaceCurrentItemWithPlayerItem:(nil)];
}