zoukankan      html  css  js  c++  java
  • IOS 播放音频

    1,播放短音频

    #import <AudioToolbox/AudioToolbox.h>
    #import "GLYViewController.h"
    static void completionCallback(SystemSoundID mySSID)
    {
    AudioServicesPlaySystemSound(mySSID);
    }
    @interface GLYViewController ()

    @end

    @implementation GLYViewController
    SystemSoundID crash;
    - (void)viewDidLoad
    {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    NSURL* crashUrl = [[NSBundle mainBundle] URLForResource:@"crash"
    withExtension:@"wav"];
    AudioServicesCreateSystemSoundID((__bridge CFURLRef)crashUrl, &crash);

    AudioServicesAddSystemSoundCompletion(crash, NULL, NULL, (void *)completionCallback, NULL);
    }
    - (IBAction)play:(id)sender {
    AudioServicesPlayAlertSound(crash);
    }

    - (void)didReceiveMemoryWarning
    {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    }

    @end

  • 相关阅读:
    MySQL事务隔离级别和MVCC
    windows环境下查看端口是否被占用
    jar找不到问题解决
    Java注解
    Fastjson
    mybatis
    Idea快捷键
    Date与String的相互转换
    Windows快捷键
    [转]linux awk命令详解
  • 原文地址:https://www.cnblogs.com/guanliyang/p/3809682.html
Copyright © 2011-2022 走看看