私はいくつかの問題を抱えています。だから私は再生/停止を伴うAvPlayerとUIButtonを持っています。また: 私は 3 つの UiViewControllers を持っています。2番目のコントローラーの最初のUIVIewControllerの最初のボタンをクリックすると、3番目のコントローラーボタンもそれぞれ逆に押される必要があります。その作り方は?何か案は?
それは単純なコードです - ボタンを押す - URL ストリームを再生し、もう一度押すと音楽を停止します。
-(IBAction)playRadioButton:(id)sender
{
if(clicked == 0) {
clicked = 1;
NSLog(@"Play");
NSString *urlAddress = @"http://URLRADIOSTREAM";
NSURL *urlStream = [NSURL URLWithString:urlAddress];
myplayer = [[AVPlayer alloc] initWithURL:urlStream];
[myplayer play];
[playRadioButton setTitle:@"Pause" forState:UIControlStateNormal];
}
else
{
NSLog(@"Stop");
[myplayer release];
clicked = 0;
[playRadioButton setTitle:@"Play" forState:UIControlStateNormal];
}
}