ผมกำลังจะสอบวันจันทร์นี้ ซึ่ง Code ต่างๆที่ผมเอามาใส่ มันรันได้ แต่ ติด อะไร นิดหน่อย ที่คิดว่าเขาถามผมแล้วไปไม่ถูกแน่ๆ
อย่างเช่น Code เล่น mp3
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad{
[super viewDidLoad];
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/Sand.mp3",[[NSBundle mainBundle] resourcePath]]];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
audioPlayer.numberOfLoops = -1;
[audioPlayer play];
}
- (IBAction)Stopsong
id)sender {
[audioPlayer stop];
}
@end
ประมาณนี้ ที่ผมไม่เข้าใจ คือ NSURL NSError NSBundle มันคือ อะไร ครับ หรือถ้าใคร เก่งมาก อธิบายการทำงาน ของ Code นี้ ทีครับ ขอบคุณครับ
อย่างเช่น Code เล่น mp3
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad{
[super viewDidLoad];
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/Sand.mp3",[[NSBundle mainBundle] resourcePath]]];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
audioPlayer.numberOfLoops = -1;
[audioPlayer play];
}
- (IBAction)Stopsong
id)sender {[audioPlayer stop];
}
@end
ประมาณนี้ ที่ผมไม่เข้าใจ คือ NSURL NSError NSBundle มันคือ อะไร ครับ หรือถ้าใคร เก่งมาก อธิบายการทำงาน ของ Code นี้ ทีครับ ขอบคุณครับ
Comment