send key commands to shell?

Hi there,

I’m a Xojo noob so hope you can bear with me:)

I’m trying to build a simple audio/music player using ffmpeg and ffplay on the Mac - I’ve just figured out how to start them as a shell and pass arguments to them.
However, there are a number of options that I need to be able to access whilst the shell is running.

For example, I want to be able to change the volume - when ran from the terminal, you do this using key commands.
How can I pass a key command (like ‘0’ or ‘)’) to a shell whilst it’s running?

I suggest you read about “interactive shell” mode in the Shell documentation. See the ExecuteMode property and sample code farther done the doc page

Are you aware that you can make an audio player entirely in XOJO using the movieplayer control to play the audio files?

Hey guys, thank you both for your suggestions.

Robert, Movieplayer - I seem to recall that was getting depreciated in favour of AVclass / AV Foundation?
I could be wrong, I will check it out:)

The main reason for using something like FFmpeg (and I’ve checked others, like Sox as well) is the multitude of file formats they can handle. In addition, the main reason or concocting something up myself is that I’m looking to do do things like sample waveform drawing.

Formats like flac, aif, wav, mp4, ogg…anyhoo, I wil have a look at the class.
FFmpeg looks like it can handle a lot, but it seems ffplay might be a tad too simple for my needs, despite the wide range of formats…

Chances are FFPlay accesses directly the hardware, a bit like the keyboard class in Xojo.

It is doubtful you will find a way to simulate that in software. your best bet would be to instruct the user how to use the keys.

Not sure whether this would be acceptable or not, but you could change the system volume using Applescript from your Xojo app, but that would change the volume for everything, not just the music player.

You would use the Async mode of the shell (theShell.Mode = 2). This allows you to send text to the shell backend as if it was typed from the keyboard. I use the “Write” function and the ChrB() option (note - ChrB is for 19r1.1 and earlier).

Create your Shell as a Global variable
Instantiate and Launch the Shell as part of a Thread’s .Run event
In your app, send the characters to the shell
Have the thread quit when the player is quit.