I am trying to use a variable defined in python file in an embedded applescript. I want the path in currentpath to be appended where I mentioned the variable in the osascript statement.
I have tried all the methods given in the link and some other links too but none of them work: Pass variable into AppleScript from python
import os
import sys
currentpath = os.path.dirname(sys.argv[0])
com = ("""osascript -e 'tell application "Terminal" to do script "afplay {0}/Sounds/storm-9s.mp3"'""".format(currentpath))
os.system(com)
All the tricks lead me to the same errors and I am not sure if the problem is with my python code or applescript.
A94HDBSGHHHD:~ user$ afplay /Sounds/storm-9s.mp3
Unspecified exception
A94HDBSGHHHD:~ user$
Update: My application requires to play multiple sound files simultaneously. Using subprocesses requires my script to pipeline the sound files and play the second file only when the first file is played completely. Thus I have to start multiple terminals to play the sounds together. e.g. My code plays a.mp3 and then before it completes playing, my code decides to play b.mp3. So it should start playing b.mp3 without stopping a.mp3 and play them both simultaneously till a.mp3 stops when the file is over and then b.mp3 stops when the file is done playing.