Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Problem controlling foobar2000 playback with python (Read 427 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Problem controlling foobar2000 playback with python

I have been trying to play songs on foobar2000 using a python program. But when I run this code, it just adds the song to a foobar playlist. It doesn't play the song. I want it to start playing the song when I run the code.

This is my code :

Code: [Select]
import subprocess

foobar_location = 'D:\\Music\\Foobar\\foobar2000.exe'
song_location = 'D:\\Music\\Rock and Pop\\Linkin Park\\Linkin Park - A Thousand Suns\\16 Blackbirds (Bonus Track).wav'

subprocess.call([foobar_location, song_location])

When I run the code, this is what happens in foobar:


I am really new to this, and I don't know if I need any extra foobar components or plugins to do this.

Re: Problem controlling foobar2000 playback with python

Reply #1
fb2k has some additional command line options you can use to customize the action that should be taken when you start it:
You can see it by running foobar2000.exe /? or as reproduced below:
Code: [Select]
Available switches:
  /add <list-of-files> - appends the specified files to the current playlist instead of replacing the playlist content and playing them immediately
  /immediate - suppresses the delay when adding files
  /play, /pause, /playpause, /prev, /next, /rand, /stop - playback controls
  /exit - exits foobar2000
  /show, /hide - shows or hides the main foobar2000 window
  /config - opens the Preferences dialog
  /command:<menu command> - invokes the specified main menu command
  /playlist_command:<context menu command> - invokes the specified context menu command on current playlist selection
  /playing_command:<context menu command> - invokes the specified context menu command on currently played track
  /context_command:<context menu command> <files> - invokes the specified context menu command on the specified files
Zao shang yong zao nong zao rang zao ren zao.
To, early in the morning, use a chisel to build a bathtub makes impatient people hot-tempered.

 

Re: Problem controlling foobar2000 playback with python

Reply #2
fb2k has some additional command line options you can use to customize the action that should be taken when you start it:
You can see it by running foobar2000.exe /? or as reproduced below:
Code: [Select]
Available switches:
  /add <list-of-files> - appends the specified files to the current playlist instead of replacing the playlist content and playing them immediately
  /immediate - suppresses the delay when adding files
  /play, /pause, /playpause, /prev, /next, /rand, /stop - playback controls
  /exit - exits foobar2000
  /show, /hide - shows or hides the main foobar2000 window
  /config - opens the Preferences dialog
  /command:<menu command> - invokes the specified main menu command
  /playlist_command:<context menu command> - invokes the specified context menu command on current playlist selection
  /playing_command:<context menu command> - invokes the specified context menu command on currently played track
  /context_command:<context menu command> <files> - invokes the specified context menu command on the specified files


Thanks for that!!
I found an option in Shell integration that allowed me to play the song on startup