使用AudioServicesPlaySystemSound播放声音时响铃音量控制
我播放苹果提供的默认/库/铃声使用AudioServicesPlaySystemSound播放声音时响铃音量控制,ios,objective-c,ios8,avaudioplayer,Ios,Objective C,Ios8,Avaudioplayer,我播放苹果提供的默认/库/铃声 AudioServicesPlaySystemSound(soundID); 声音播放完美,但现在我想从我的应用程序中增加和减少音量 我使用了下面的代码 musicPlayer = [MPMusicPlayerController applicationMusicPlayer]; musicPlayer.volume = 0.0625; 但这在iOS7.0中被弃用。我想在最新的iOS 8.0中运行应用程序 我有什么办法可以做到这一点吗 谢谢 我
AudioServicesPlaySystemSound(soundID);
声音播放完美,但现在我想从我的应用程序中增加和减少音量
我使用了下面的代码
musicPlayer = [MPMusicPlayerController applicationMusicPlayer];
musicPlayer.volume = 0.0625;
但这在iOS7.0中被弃用。我想在最新的iOS 8.0中运行应用程序
我有什么办法可以做到这一点吗
谢谢 我在iOS8中完美地使用了以下代码:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"file.mp3"]
AVAudioPlayer *player = [[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:nil] autorelease];
player.volume = 1.0f;
[player prepareToPlay];
[player setNumberOfLoops:0];
[player play];
你们在小路上经过什么?您是在播放捆绑包中的文件还是系统声音文件?Dhaval我使用捆绑包中的mp3:NSArray*path=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);NSString*documentsDirectory=[paths objectAtIndex:0];NSString*path=[DocumentsDirectoryStringByAppendingPathComponent:@“file.mp3”];