2016-08-03 92 views
0
SystemSoundID soundID6; // declaration  
NSURL *gamePlayMusic = [NSURL fileURLWithPath:[[NSBundle 
mainBundle]pathForResource:@"song1" ofType:@"wav"]]; 

AudioServicesCreateSystemSoundID((__bridge CFURLRef)Music,&soundID6);  
AudioServicesPlaySystemSound(soundID6); //running of music 

我可以知道編寫完成/完成後再次運行此音樂的代碼。如何在ios sdk中一次又一次地運行音頻文件

回答

1
1. Add AVKit.framework. 
2.create a global webview object like UIWebView* audioPlayerView; 
3.create a button action for playing audio file 
4.your mp3 file add in to your bundel. 

    -(IBAction)playAudioFile:(UIButton*)sender 
    { 
     NSString *path = [[NSBundle mainBundle] pathForResource:@"your file name" ofType:@"mp3"]; 
     NSURL *targetURL = [NSURL fileURLWithPath:path]; 
     NSURLRequest *request = [NSURLRequest requestWithURL:targetURL]; 
     [audioPlayerView loadRequest:request]; 
     [audioPlayerView setScalesPageToFit:YES]; 
     [self.view addSubview:audioPlayerView]; 
    } 
相關問題