iOS 代码创建无声音乐方法
发表于:2024-11-24 作者:热门IT资讯网编辑
编辑最后更新 2024年11月24日,代码创建无声音乐方法const char bytes[] = {0x52, 0x49, 0x46, 0x46, 0x26, 0x0, 0x0, 0x0, 0x57, 0x41, 0x56, 0x45,
代码创建无声音乐方法
const char bytes[] = {0x52, 0x49, 0x46, 0x46, 0x26, 0x0, 0x0, 0x0, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6d, 0x74, 0x20, 0x10, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x44, 0xac, 0x0, 0x0, 0x88, 0x58, 0x1, 0x0, 0x2, 0x0, 0x10, 0x0, 0x64, 0x61, 0x74, 0x61, 0x2, 0x0, 0x0, 0x0, 0xfc, 0xff};
NSData* data = [NSData dataWithBytes:bytes length:sizeof(bytes)]; NSString * docsDir = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]; // Build the path to the database file NSString * filePath = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent: @"background.wav"]]; [data writeToFile:filePath atomically:YES];