美文网首页
AudioServicesPlaySystemSound 播放铃

AudioServicesPlaySystemSound 播放铃

作者: ios_暗夜行者 | 来源:发表于2024-07-18 14:54 被阅读0次

    AudioServicesPlaySystemSound 播放铃声无效
    解决方法:
    1.在设置-》声音-〉声音和提醒
    设置音量大于0即可
    2.静音模式无法播放铃声

    +(void)playClickSound
    {
        NSURL *fileURL = [[NSBundle mainBundle] URLForResource:@"click_sound.mp3" withExtension:nil]; //filename can include extension e.g. @"bang.wav"
        if (fileURL)
        {
            SystemSoundID theSoundID;
            OSStatus error = AudioServicesCreateSystemSoundID((__bridge CFURLRef)fileURL, &theSoundID);
            if (error == kAudioServicesNoError)
            {
                AudioServicesPlaySystemSoundWithCompletion(theSoundID, ^{
                    AudioServicesDisposeSystemSoundID(theSoundID);
                });
            }
        }
    }
    

    相关文章

      网友评论

          本文标题:AudioServicesPlaySystemSound 播放铃

          本文链接:https://www.haomeiwen.com/subject/erirhjtx.html