I have this code called CountDown Program. What my program does is:
Count down from 60.
Play a sound file (
alarm.wav
) when the countdown reaches zero. This means the code needs to do the following:Pause for one second in between displaying each number in the countdown by calling
time.sleep()
.Call
subprocess.Popen()
to open the sound file with the default application.
Here's the code for it:
import time , subprocess,os
from subprocess import call
def countDown():
for i in range (10):
print(i, end='')
time.sleep(1)
countDown()
subprocess.call([ 'bomb.mp3'])
When I run this I get:
Error: File not Found
I tried with:
subprocess.call([ 'home/username/bomb.mp3']) # location specified
But I got:
Error: Permission denied
Then, I tried with Popen
:
subprocess.Popen(['start', 'bomb.mp3'], shell=True)
But I got:
Error: 0123456789bomb.mp3: 1: start: not found
I am not quite sure why this code does not work on Ubuntu, because it works fine on Windows.
What I can do for this? Is there any method to open mp3 files using Python on Ubuntu 20.04 LTS or am I missing out any argument?
Thanks in advance.