I want to connect my Mac to an external display a little distance away via HDMI, and play audio from the external display when an action is triggered. The audio is output as text using the AppleScript say command. Is there a way to get a list of audio output devices connected to the Mac and switch between them?
In MBS, I found a sample app that gets audio input devices such as microphones and speakers, but I can’t find a way to get the audio output device I want.
I had the issue - I could get the names of all the audio devices but choosing them would not change the audio inputs and outputs displayed in system preferences.
I was able to get the device ID with AUPlayerMBS and specify the OutputDeviceID with CoreAudioPlayerMBS, and then control only the sound that the app makes. I was able to run it with the MBS sample app.
However, I am currently struggling to use this method to make audio files embedded in a program or the voice of the say command in AppleScript play on a specified device.
There may be another way to change the system settings. My purpose was not to change the system settings, but to control the sound emitted by the app, so I’m satisfied. Sorry I can’t help you.
I’ve been there too not so long ago. The MBS plugins can either speak using the default output device or speak to an audio file (that you can then play to a different output device once the speech/recording has ended).
I wasn’t able to make it speaking to another output device (even asked here in the forum, if you want to follow the discussion).
In other words, even if I use Xojo’s standard functions or the MBS plugins, there is no way to output only the sound produced by the app (embedded .mp3 files or embedded AppleScript Say commands) to an external LG display.
In terms of operation, there is currently no need to speak into the input device or record it, so I am having trouble controlling only the output. I hope I can solve this problem by using recordings etc.
For the AppleScript’s Say command, you’re right (as far as I’ve tried), but you can fairly well play mp3 files to another output, like the LG display using the AUPlayerMBS class.
Here’s a quick example:
Add a property to your window (or where it suits your needs):
ap As AUPlayerMBS
Then:
ap=new AUPlayerMBS
if ap.LoadFile(File) then 'Your mp3 folderitem
ap.CurrentDeviceID=IDForYourLGDevice 'you must get that ID using another function (e.g. loop thru all available identifiers and find which one has the correct name)
ap.OutputVolume=1
ap.InputEnabled(0)=True 'Doesn't sound intuitive, but the following 4 lines are needed
ap.InputEnabled(1)=True
ap.InputVolume(0)=1
ap.InputVolume(1)=1
ap.Play
end if