IOS学习:AVAudioPlayer播放音乐文件及读取ipod库中的音乐文件
下面是ipad上的调试效果
 
 
下面是代码,代码中都有注释:
[cpp]
//  
//  RootViewController.h  
//  SoundDemo  
//  
//  Created by on 13-6-21.  
//  Copyright (c) 2013年 DoubleMan. All rights reserved.  
//  
 
#import <UIKit/UIKit.h>  
#import <AVFoundation/AVFoundation.h>  
#import <MediaPlayer/MediaPlayer.h>  
 
@interface RootViewController : UIViewController <AVAudioPlayerDelegate> 
{ 
    AVAudioPlayer *player; 
} 
 
@property (nonatomic, retain) AVAudioPlayer *player; 
@property (nonatomic, retain) UISlider *slider; 
@property (nonatomic, retain) NSTimer *timer; 
 
@end 
//
//  RootViewController.h
//  SoundDemo
//
//  Created by on 13-6-21.
//  Copyright (c) 2013年 DoubleMan. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>
@interface RootViewController : UIViewController <AVAudioPlayerDelegate>
{
    AVAudioPlayer *player;
}
@property (nonatomic, retain) AVAudioPlayer *player;
@property (nonatomic, retain) UISlider *slider;
@property (nonatomic, retain) NSTimer *timer;
@end
[cpp]
//  
//  RootViewController.m  
//  SoundDemo  
//  
//  Created by on 13-6-21.  
//  Copyright (c) 2013年 DoubleMan. All rights reserved.  
//  
 
#import "RootViewController.h"  
 
@interface RootViewController () 
 
@end 
 
@implementation RootViewController 
 
@synthesize player; 
@synthesize slider; 
@synthesize timer; 
 
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
        // Custom initialization  
         
         
    } 
    return self; 
} 
 
- (void)viewDidLoad 
	
相关新闻>>
- 发表评论
- 
				
- 最新评论 进入详细评论页>>









![[iPhone中级]iPhone团购信息客户端的开发 (二)](/uploads/allimg/131022/200H11235-0-lp.png)
