Sunday, April 24, 2011

python, winamp interface, system volume interface

Interfacing with winamp:
Use (download this and put in your python folder)
ActivePython (this is needs for the 32wingui)
nircmd (this is for interfacing with system features)

How it works:
  • we import relevant libraries
  • create an instance called "w" that is a winamp object 
    • See the first few lines of the code!
  • we can now interact with "w", by calling its functinons
  • e.g. w.getTrackStatus(), this will return a value (playing, paused, stopped)
  • See the code for a bunch of commands that is used. (open and you can see all the functions it supports)
Now for the system interface
  • I found this fairly cool program "nircmd" which when opened with arguments, you can interface to a lot of system properties. The ones i wanted (volume) were conveniently available
  • To run something we go --> nircmd changesysvolume -2000
    • This will decrease the system volume by a factor of 2000/some#
  • to call this in python
    • import os
    • os.system('nircmd changesysvolume 2000)
  • this assumes that you have put nircmd in the same folder as you python files
  • nircmd also has a bunch of other commands that you can use, look them up and you can call them in the same way.

For the code: see the folder pc_winamp_interface, (don't download the .exe version in dist)