Play a sound with [Androwish] Subcommand of the [borg] command Documentation: [http://www.androwish.org/home/wiki?name=Android+facilities] **List available sound files** [HaO] 2020-08-21: This is only an application page of great Androwish by a novice user. All available sound files may be found by Android content queries ([borg]): ***Internal List*** ====== % set cursor [borg content query content://media/internal/audio/media/] cursor_1 % $cursor columnnames _id _data _display_name _size mime_type date_added is_drm date_modified title title_key duration artist_id composer album_id track year is_ringtone is_music is_alarm is_notification is_podcast bookmark album_artist artist_id:1 artist_key artist album_id:1 album_key album % $cursor move 1 1 % $cursor getrow] _id 5 _data /system/media/audio/alarms/Alarm_Beep_01.ogg _display_name Alarm_Beep_01.ogg _size 16130 mime_type application/ogg date_added 534 is_drm 0 date_modified 1230768000 title {Piezo Alarm} title_key {G91[E)?)KA} duration 2112 artist_id 1 composer {} album_id 1 track 0 year {} is_ringtone 0 is_music 0 is_alarm 1 is_notification 0 is_podcast 0 bookmark {} album_artist {} artist_id:1 1 artist_key  artist album_id:1 1 album_key )?)KAM-183121033 album alarms % $cursor close ====== N.B.: If you use tkcon to connect to AndroWish and test, take care that non-ASCII characters are not shown correctly. On my phone, there is a sound with the title "Boötes". The title is shown as follows on tkcon: "Boötes". Within Androwish, the writing is correct, e.g. when displayed via a Tk widget. ***External List*** The list of external (not belonging to the OS but to some Apps) may be queried the same way, but changing the query to: ====== % set cursor [borg content query content://media/external/audio/media/] ====== **Use Sound Titles** To index the sound files, the columns "_id" and "title" are important: * _id is needed to play the sound * title is the identification, which I use for user interface and to save the user choice. So, the following operations may be done: ***Retrieve list of available titles*** A dict may be build-up with a title to ID index: ====== # Return a dict of available sounds as: # key: title # value: ID proc soundsGet {} { set resDict {} set cursor [borg content query content://media/internal/audio/media/] set columnNames [$cursor columnnames] set indexID [lsearch -exact $columnNames _id] set indexTitle [lsearch -exact $columnNames title] while {[$cursor move 1]} { dict set resDict [$cursor getstring $indexTitle] [$cursor getint $indexID] } $cursor close return $resDict } ====== So, it is easy to play the sound from its title: ====== set dSound [soundsGet] borg beep content://media/internal/audio/media/[dict get $dSound $title] ====== ***Play a sound with a given title*** ====== # Play an internal sound with a given title proc soundPlay {title} { set cursor [borg content query content://media/internal/audio/media/] set columnNames [$cursor columnnames] set indexID [lsearch -exact $columnNames _id] set indexTitle [lsearch -exact $columnNames title] while {[$cursor move 1]} { if {[$cursor getstring $indexTitle] eq $title} { borg beep content://media/internal/audio/media/[$cursor getint $indexID] break } } $cursor close } ======