IOS基本声音播放类
来源:网络 责任编辑:栏目编辑 发表时间:2013-07-01 05:37 点击:次
一个基本的IOS声音播放支持类,注释不多对付看吧
#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>
@interface Sound_Base : NSObject{
float volume;
BOOL is_turnON;
AVAudioPlayer *mainMenuMusic_Player;
SystemSoundID btn_soundID;
SystemSoundID err_soundID;
}
@property (nonatomic) BOOL is_turnON;
@property (nonatomic) float volume;
@property (nonatomic,retain) AVAudioPlayer *mainMenuMusic_player;
@property (nonatomic) SystemSoundID btn_soundID;
@property (nonatomic) SystemSoundID err_soundID;
-(void)setSoundSwitch:(BOOL)sound_state;
-(void)setUIVolume:(float)f_volume;
-(void)initSound;
-(void)playSysSound:(SystemSoundID)sys_sID;
-(void)stopAllMusic;
#import "Sound_Base.h"
@implementation Sound_Base
@synthesize mainMenuMusic_player;
@synthesize volume;
@synthesize is_turnON;
@synthesize btn_soundID;
@synthesize err_soundID;
-(void)dealloc{
if (self.mainMenuMusic_player.playing) {
[self.mainMenuMusic_player stop];
}
[mainMenuMusic_player release];
if (btn_soundID) {
AudioServicesDisposeSystemSoundID(btn_soundID),btn_soundID = 0;
}
if (err_soundID) {
AudioServicesDisposeSystemSoundID(err_soundID),err_soundID = 0;
}
[super dealloc];
}
-(void)initSound{
NSString *mainMenuMusic_path = [ [NSBundle mainBundle] pathForResource:@"bgm_0" ofType:@"aac"];
NSURL *mainMenuMusic_url = [NSURL fileURLWithPath:mainMenuMusic_path];
self.mainMenuMusic_player = [ [AVAudioPlayer alloc] initWithContentsOfURL:mainMenuMusic_url error:nil];
self.mainMenuMusic_player.numberOfLoops = -1;
[self.mainMenuMusic_player prepareToPlay];
NSString *btnSound_path = [[NSBundle mainBundle] pathForResource:@"sys_click&
#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>
@interface Sound_Base : NSObject{
float volume;
BOOL is_turnON;
AVAudioPlayer *mainMenuMusic_Player;
SystemSoundID btn_soundID;
SystemSoundID err_soundID;
}
@property (nonatomic) BOOL is_turnON;
@property (nonatomic) float volume;
@property (nonatomic,retain) AVAudioPlayer *mainMenuMusic_player;
@property (nonatomic) SystemSoundID btn_soundID;
@property (nonatomic) SystemSoundID err_soundID;
-(void)setSoundSwitch:(BOOL)sound_state;
-(void)setUIVolume:(float)f_volume;
-(void)initSound;
-(void)playSysSound:(SystemSoundID)sys_sID;
-(void)stopAllMusic;
#import "Sound_Base.h"
@implementation Sound_Base
@synthesize mainMenuMusic_player;
@synthesize volume;
@synthesize is_turnON;
@synthesize btn_soundID;
@synthesize err_soundID;
-(void)dealloc{
if (self.mainMenuMusic_player.playing) {
[self.mainMenuMusic_player stop];
}
[mainMenuMusic_player release];
if (btn_soundID) {
AudioServicesDisposeSystemSoundID(btn_soundID),btn_soundID = 0;
}
if (err_soundID) {
AudioServicesDisposeSystemSoundID(err_soundID),err_soundID = 0;
}
[super dealloc];
}
-(void)initSound{
NSString *mainMenuMusic_path = [ [NSBundle mainBundle] pathForResource:@"bgm_0" ofType:@"aac"];
NSURL *mainMenuMusic_url = [NSURL fileURLWithPath:mainMenuMusic_path];
self.mainMenuMusic_player = [ [AVAudioPlayer alloc] initWithContentsOfURL:mainMenuMusic_url error:nil];
self.mainMenuMusic_player.numberOfLoops = -1;
[self.mainMenuMusic_player prepareToPlay];
NSString *btnSound_path = [[NSBundle mainBundle] pathForResource:@"sys_click&
相关新闻>>
- 发表评论
-
- 最新评论 更多>>