Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用AudioServicesPlaySystemSound播放声音时响铃音量控制_Ios_Objective C_Ios8_Avaudioplayer - Fatal编程技术网

使用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”];