How to use wx.MediaCtrl to play Mp3s

It’s been years since I experimented with wx.MediaCtrl, but I know it used to playback MP3s on Windows. I tried updating my old MP3 player code to the latest wxPython (4.1.1) but now it doesn’t work and there are no errors.

I am attaching my code. Could someone tell me what I’m doing wrong? Note, I am using Python 3.9 on MacOS Mojave. (5.6 KB)

I tried this on Windows 10 as well. On that OS, EVT_MEDIA_LOADED is never fired with this code, but that event does fire on macOS.

I don’t know why that happens though.

Hi Mike,

  I don't have time to look at your code right now.  Maybe tonight

or over the weekend.

  But FWIW, I can confirm for now that I play MP3 files using

wxMediaCtrl using wxPython 4.1.1 on macOS Catalina.


I think I just figured it out. I was using a toggle button and then binding to wx.EVT_BUTTON, which doesn’t work.

Hi Mike,

Okay, I peeked. I said I wouldn’t until later, but I did.

  Your code doesn't work on either macOS Catalina or Windows 10. 

When I press your “Play” button, your “on_play” method is not
invoked. That is why you don’t hear anything.

  I added "self.media_ctrl.Play()" to your loadMusic method and the

file started playing on macOS but not WIndows. This suggests to
me that the problem is in your buttons and event handlers, not in
the MediaCtrl per se.

  I'd have to dig more into my own code to see about the failure of

the wx.EVT_MEDIA_LOADED event on Windows, which I can confirm in
your code, and I truly don’t have time to do that right now.


I got it working on my Mac. I haven’t had a chance to try it again on Windows though. My current issue is that when I go to skip a track, the playback slider stops updating. But if I pause or stop the track and then hit play again, the slider starts updating again.

I really don’t know why. The skip method I wrote calls the stop method before doing anything else, so you would think that stopping and starting would be no different than skipping.

I added ObjectListView and eyeD3 to the mix so I can load the MP3 tags and display what songs are in my play list.

My latest version of the code is attached. (9.5 KB)