AppleScript VLC – Add Multiple Files to VLC from List Results

applescriptaudiofilemakervlc

I have a FileMaker Pro database of music files which uses AppleScript to pass it's search results into an iTunes playlist.

I would like to use VLC instead of iTunes to play the audio files since I have a number of FLAC files which iTunes will not play.

I haven't been able to figure out how to pass the AppleScript results to VLC. It's easy to use AppleScript to get VLC to play a folder of music using:

tell application "VLC"
    OpenURL "file:///Volumes/NoDoubt/Music/Rock Pop/PQR/Pink Floyd/Wish You Were Here/"
    play
end tell

However, if I wanted to instead play a mix of songs from a variety of folders I need to be able to insert each file path into the VLC player.

This is what the AppleScript returned search results from FileMaker Pro looks like:

{"NoDoubt:Music:Rock Pop:ABC:The Beatles:Abbey Road:01_come_together_alac.m4a", "NoDoubt:Music:Rock Pop:DEF:Fleetwood Mac:Rumours:01_second_hand_news_alac.m4a", "NoDoubt:Music:Rock Pop:MNO:Van Morrison:hymns_to_the_silence_disc_1:1-02_i'm_not_feeling_it_anymore_alac.m4a", "NoDoubt:Music:Rock Pop:PQR:Pink Floyd:Wish You Were Here:04_wish_you_were_here_alac.m4a"}

How can I pass the search results of these individual tracks to VLC to play?

Best Answer

This AppleScript code works for me using the latest version of macOS Mojave.

As a side note, I understand your list is generated from searching a FileMaker database. However, I do not have that application nor do I know what your code is to search the database file, so I "hard coded" the file list just for example purposes.

set theSongs to {"NoDoubt:Music:Rock Pop:ABC:The Beatles:Abbey Road:01_come_together_alac.m4a", ¬
    "NoDoubt:Music:Rock Pop:DEF:Fleetwood Mac:Rumours:01_second_hand_news_alac.m4a", ¬
    "NoDoubt:Music:Rock Pop:MNO:Van Morrison:hymns_to_the_silence_disc_1:1-02_i'm_not_feeling_it_anymore_alac.m4a", ¬
    "NoDoubt:Music:Rock Pop:PQR:Pink Floyd:Wish You Were Here:04_wish_you_were_here_alac.m4a"}

set theSongsAlias to {}

repeat with thisSong in theSongs
    set end of theSongsAlias to alias thisSong
end repeat

tell application "VLC" to open theSongsAlias