次のように numberOfLoops メソッドを呼び出す場合:
[_player setNumberOfLoops:-1];
次のエラーが表示されます。
-[AVPlayer setNumberOfLoops:]: unrecognized selector sent to instance 0x7d52d30
これはどのように修正できますか?
コード:
ヘッダ:
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
@interface ViewController : UIViewController {
}
@property (strong, nonatomic) AVAudioPlayer *player;
- (IBAction)playMusic:(id)sender;
@end
実装:
#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)playMusic:(id)sender {
_player = [AVPlayer playerWithURL:[NSURL URLWithString:@"http://urlpath.wav"]];
[_player setNumberOfLoops:-1];
[_player prepareToPlay];
[_player play];
}
@end
お時間をいただきありがとうございます。
Yoni201.