-1

I used pygame and mplayer library to play a m4a music file in python languages,but all failed. Is there a library i can use to play m4a file in python?

here is my code:

pipes = dict(stdin=PIPE, stdout=PIPE, stderr=PIPE)
mplayer = Popen(["mplayer", r"C:\Users\sam\PycharmProjects\untitled\music.m4a"], **pipes)
# to control u can use Popen.communicate
mplayer.communicate(input=b">")
sys.stdout.flush()

i used the pycharm ,and the result is : Traceback (most recent call last): File "C:/Users/sam/PycharmProjects/untitled/tt.py", line 23, in mplayer = Popen(["mplayer", r"C:\Users\sam\PycharmProjects\untitled\music.m4a"], **pipes) File "C:\Users\sam\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 707, in init restore_signals, start_new_session) File "C:\Users\sam\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 990, in _execute_child startupinfo) FileNotFoundError: [WinError 2] 系统找不到指定的文件。

user9978491
  • 11
  • 1
  • 2

1 Answers1

0

Here is a link to a good thread that I believe answers the exact same thing that you are having issues with.

Play m4a in python script with mplayer

  • 1
    i have tried the Popen way,but the result of running is "FileNotFoundError: [WinError 2]".I have put the m4a file with the code file in the same path. – user9978491 Jun 22 '18 at 13:43
  • Could you possibly edit your question and share a snippet of your code? –  Jun 22 '18 at 13:46
  • 1
    here is my code:pipes = dict(stdin=PIPE, stdout=PIPE, stderr=PIPE) mplayer = Popen(["mplayer", r"C:\Users\sam\PycharmProjects\untitled\music.m4a"], **pipes) # to control u can use Popen.communicate mplayer.communicate(input=b">") sys.stdout.flush() – user9978491 Jun 22 '18 at 13:47
  • Try moving the file to another location and see if you are getting the same error. –  Jun 22 '18 at 13:53
  • 1
    i changed the m4a file to "c:\",but also the same result. – user9978491 Jun 22 '18 at 13:56
  • I know it seems weird, but this is the only solution I can think of. Try changing the file destination to this: C:\\Users\\sam\\PycharmProjects\\untitled\\music.m4a –  Jun 22 '18 at 14:01