#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    12
    Rep Power
    0

    how to import media player to python?


    hello,

    can someone tell me how to import a windows media player into python.what are the modules to be imported?.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    35
    There aren't any in the standard library. The winsound module is as close as it gets, but that just beeps and plays WAV files.

    There are probably some out there (I started using the bass library with ctypes at one point, which worked very well until I got a bit lost).

    On Windows, one of the core technologies is COM, which is a common-interface between a lot of different programs and languages. If there is a COM control written in one language, and your language also supports COM, you can use that control without too much hassle.

    Python supports COM if you have the Win32 extensions, and Media Player is controllable with COM, so you can do...

    Code:
    from win32com.client import Dispatch
    
    mp = Dispatch("WMPlayer.OCX.7")
    
    tune = mp.newMedia("c:\\music\\song.mp3")
    mp.currentPlaylist.appendItem(tune)
    mp.controls.play()
    Not just a windows media player, but The Windows Media Player.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Location
    Albuquerque, New Mexico
    Posts
    137
    Rep Power
    11
    Well, you could either use COM, or, you could try making a small media player in pygame (or there are a few other libs)

IMN logo majestic logo threadwatch logo seochat tools logo