Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Internet Explorer alert
This browser is not recommended for use with smartdevicelink.com, and may not function properly. Upgrade to a different browser to guarantee support of all features.
close alert
To Top Created with Sketch. To Top
To Bottom Created with Sketch. To Bottom
iOS Guides
Playing Audio Indications

Playing Audio Indications (RPC v5.0+)

You can pass an uploaded audio file's name to SDLTTSChunk, allowing any API that takes a text-to-speech parameter to pass and play your audio file. A sports app, for example, could play a distinctive audio chime to notify the user of a score update alongside an Alert request.

Note

On Manticore, audio indications work best in Google Chrome, Mozilla Firefox, or Microsoft Edge. Audio indications do not work in Apple Safari at this time.

Uploading the Audio File

The first step is to make sure the audio file is available on the remote system. To upload the file use the SDLFileManager.

SDLFile *audioFile = [[SDLFile alloc] initWithFileURL:<#File location on disk#> name:<#Audio file name#> persistent:<#True if the file will be used beyond just this session#>];
[self.sdlManager.fileManager uploadFile:audioFile completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError * _Nullable error) {
    <#audio file is ready if success is true#>
}];
let audioFile = SDLFile(fileURL: <#File location on disk#>, name: <#Audio file name#>, persistent: <#True if the file will be used beyond just this session#>)
sdlManager.fileManager.upload(file: audioFile) { (success, bytesAvailable, error) in
    <#audio file is ready if success is true#>
}

For more information about uploading files, see the Uploading Files guide.

Using the Audio File

Now that the file is uploaded to the remote system, it can be used in various RPCs, such as Speak, Alert, and AlertManeuver. To use the audio file in an alert, you simply need to construct a SDLTTSChunk referring to the file's name.

SDLAlert *alert = [[SDLAlert alloc] init];
alert.ttsChunks = [SDLTTSChunk fileChunksWithName:<#Audio file name#>];
[self.sdlManager sendRequest:alert];
let alert = SDLAlert()
alert.ttsChunks = SDLTTSChunk.fileChunks(withName: <#Audio file name#>)
sdlManager.send(alert)
View on GitHub.com
Previous Section Next Section