mmcli interactive sessions

After executing any test scripts named on its command line, mmcli starts an interactive session that allows you to enter media commands and see their results.

The interactive session is helpful for learning built-in mmcli commands (keywords) as well as multimedia API commands because you can use the help command to list all available commands. These include the keywords and the APIs of any loaded components. The session also provides tab completion of partially entered command names and lets you navigate the list of previous commands using the up and down arrow keys.

Note: Some commands, notably repeat and loop, work only in test scripts. You can't use them in interactive mode.

Interactive session example

The following interactive session shows how to use the Metadata Provider Library (libmd) to read metadata from an MP3 file:
# mmcli
> load
Unable to load DLL "": Library cannot be found.
005 Command 'load' failed (-1, errno 2); No such file or directory
> load
> mmmd_session_open /fs/usb0
010 Command 'mmmd_session_open':
sessionID: 1
> mmmd_get 1 /tmp/music/tracks/one.mp3 md_title::artist,album,\
                samplerate,mediatype 0
054 Command 'mmmd_get':
metadata: md_title_artist::U2
md_title_album::Achtung Baby
md_title_comment::Download from
> mmmd_session_close 1
> quit

Because the first load command specifies an incorrect library name, mmcli outputs an error message. The second command names the correct library, so mmcli loads the defined API and doesn't output anything.

The argument to mmmd_session_open is the mountpoint of the device that metadata is being extracted from (in this case, a USB stick). The command outputs the numeric ID of the new session, which must be used as the first argument in the mmmd_get call. The second argument to mmmd_get provides the path of the track whose metadata we're extracting. Alternatively, you could use the local command at an earlier point to set this variable locally and then reference it in the argument by using the percent sign (%) in front of its name. The third argument lists the fields that we're requesting. The fourth argument must be 0 to tell libmd that there's no preferred plugin to use.

The mmmd_get command outputs the names and values of all metadata fields that it successfully read. The duration (track length) is given in milliseconds while the bit rate and sample rate are given in Hertz (Hz). The width and height fields don't apply to audio tracks, so no metadata is retrieved for these fields.

Finally, the session ID is passed into the mmmd_session_close call, which doesn't output anything.

Note: It's not necessary to call mmmd_init and mmmd_terminate as the first and last libmd functions because mmcli does this for you.