How can I embed a sound annotation using Obj-C in iOS?

Q:

How can I embed a sound annotation using Obj-C in iOS?

A:

The following code shows how this can be accomplished:

Sound *soundAnnotation = [Sound CreateSoundWithRect:[pdfDoc GetSDFDoc]

pos:pdfRect

icon:e_Speaker];

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);

NSString *appCachePath = ([paths count] > 0) ? [paths objectAtIndex:0] : @""; // App Caches path

NSString *fileName = [NSString stringWithFormat:@“sample.wav”];

NSString *soundPath = [appCachePath stringByAppendingPathComponent:fileName];

[soundData writeToFile:soundPath atomically:NO];

MappedFile *embed_file = [[MappedFile alloc] initWithFilename:soundPath];

FilterReader *mystm = [[FilterReader alloc] initWithFilter:embed_file];

Obj* stream = [[pdfDoc GetSDFDoc] CreateIndirectStream:mystm];

[stream PutName:@“Type” name:@“Sound”];

[stream PutNumber:@“R” value:16000.0];

[soundAnnotation SetSoundStream:stream];