wxPython mediactrl problem

Hi,

I have been trying to incorporate the wxPython mediactrl into a Music
player program in am writng in Python. I am running the program in
Win7 and XP.

I have used the program player_skeleton2.py as a guide to the use of
mediactrl control. I have run this program and it runs fine on Win7
and Xp and plays music fine.

Unfortunately, I have not been able to play any file in my program. I
have assumed that all one needs to do is to define the control, load
the file and play it. It apparently loads the file, but does not play.

I then tried to reproduce the problem by testing my assumption above.
I removed what I thought are the unnecessary bits to reproduce the
problem in the player_skeleton2.py program and tried to run it. It did
not run! Ihave included the program and the output below.

I am sure some crucial step is missing from it. But what? I have been
at it for many hours and still cannot find the missing piece.

I must say that I am rather new to wxPython.

Thanks for any help

============ Output ===================
F:\My Programs\Python\Test Programs\music_player_v2>tryplay.py
F:\z1.mp3
Cannot Play
-1
===================== Program =================

···

#----------------------------------------------------------------------
# player_skeleton2.py
#
# Created: 04/15/2010
#
# Author: Mike Driscoll - mike@pythonlibrary.org
#----------------------------------------------------------------------

import os
import wx
import wx.media
import wx.lib.buttons as buttons

class MediaPanel(wx.Panel):
    """"""

#----------------------------------------------------------------------
    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent=parent)
        self.mediaPlayer = wx.media.MediaCtrl(self)
        dlg = wx.FileDialog(self, "Select Library") # Display
dialog box
        if dlg.ShowModal() == wx.ID_OK: # If OK
pressed -
            File=dlg.GetPath() # Get path selected
            dlg.Destroy()

        print File
        if not self.mediaPlayer.Load(File):
            print "Cannot Load"
        else:
            self.mediaPlayer.SetInitialSize()

            if not self.mediaPlayer.Play():
                print "Cannot Play"
          print self.mediaPlayer.GetState()
            else:
          print self.mediaPlayer.GetState()

class MediaFrame(wx.Frame):

#----------------------------------------------------------------------
    def __init__(self):
        wx.Frame.__init__(self, None, wx.ID_ANY, "Python Music
Player")
        panel = MediaPanel(self)

if __name__ == "__main__":
    app = wx.App(False)
    frame = MediaFrame()
    frame.Show()
    app.MainLoop()

Is it just the one file or are there multiple files that won't play? I
copied most of the code from the wxPython demo. Since writing that
code, I've switched to using this mplayer wrapper instead:
http://mplayerctrl.dav1d.de/docs/

It seems to work better, although finding the right version of mplayer
on Windows can be a little annoying. If you stick with the default wx
media player, then I recommend looking at the Demo code too. As I
recall, MediaCtrl is kind of fragile.

···

On Nov 8, 12:22 am, Narayanan Mangalath <narayanan.mangal...@gmail.com> wrote:

Hi,

I have been trying to incorporate the wxPython mediactrl into a Music
player program in am writng in Python. I am running the program in
Win7 and XP.

I have used the program player_skeleton2.py as a guide to the use of
mediactrl control. I have run this program and it runs fine on Win7
and Xp and plays music fine.

Unfortunately, I have not been able to play any file in my program. I
have assumed that all one needs to do is to define the control, load
the file and play it. It apparently loads the file, but does not play.

I then tried to reproduce the problem by testing my assumption above.
I removed what I thought are the unnecessary bits to reproduce the
problem in the player_skeleton2.py program and tried to run it. It did
not run! Ihave included the program and the output below.

I am sure some crucial step is missing from it. But what? I have been
at it for many hours and still cannot find the missing piece.

I must say that I am rather new to wxPython.

Thanks for any help

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Thanks Mike.
I installed SMPlayer and the MPlayerCtrl and am able to get a file to
play. I have a couple of further questions on it.

1. When I run the program (.py file) by double clicking it, it also
opens a command window for the mplayer.exe. This is very annoying. Is
there a way for it not to open the command window?
2. Is it possible to compile the Pyhton program (py2exe for example)
so that the I can run it anywhere without the target computer having
to install the mplayer and the MplayerCtrl?

With pymedia for example, I do not have the above two problems. But
pymedia is not being developed now and I do not want to use it if I
can help it.

Thanks again for your help Mike.

Naru Mangalath

···

On Nov 8, 10:09 pm, Mike Driscoll <kyoso...@gmail.com> wrote:

On Nov 8, 12:22 am, Narayanan Mangalath > > > > <narayanan.mangal...@gmail.com> wrote:
> Hi,

> I have been trying to incorporate the wxPython mediactrl into a Music
> player program in am writng in Python. I am running the program in
> Win7 and XP.

> I have used the program player_skeleton2.py as a guide to the use of
> mediactrl control. I have run this program and it runs fine on Win7
> and Xp and plays music fine.

> Unfortunately, I have not been able to play any file in my program. I
> have assumed that all one needs to do is to define the control, load
> the file and play it. It apparently loads the file, but does not play.

> I then tried to reproduce the problem by testing my assumption above.
> I removed what I thought are the unnecessary bits to reproduce the
> problem in the player_skeleton2.py program and tried to run it. It did
> not run! Ihave included the program and the output below.

> I am sure some crucial step is missing from it. But what? I have been
> at it for many hours and still cannot find the missing piece.

> I must say that I am rather new to wxPython.

> Thanks for any help

Is it just the one file or are there multiple files that won't play? I
copied most of the code from the wxPython demo. Since writing that
code, I've switched to using this mplayer wrapper instead:http://mplayerctrl.dav1d.de/docs/

It seems to work better, although finding the right version of mplayer
on Windows can be a little annoying. If you stick with the default wx
media player, then I recommend looking at the Demo code too. As I
recall, MediaCtrl is kind of fragile.

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

If you run your application with pythonw.exe, you won’t get that annoying command window.

···

On Tue, Nov 9, 2010 at 3:06 AM, Narayanan Mangalath narayanan.mangalath@gmail.com wrote:

Thanks Mike.

I installed SMPlayer and the MPlayerCtrl and am able to get a file to

play. I have a couple of further questions on it.

  1. When I run the program (.py file) by double clicking it, it also

opens a command window for the mplayer.exe. This is very annoying. Is

there a way for it not to open the command window?

  1. Is it possible to compile the Pyhton program (py2exe for example)

so that the I can run it anywhere without the target computer having

to install the mplayer and the MplayerCtrl?

With pymedia for example, I do not have the above two problems. But

pymedia is not being developed now and I do not want to use it if I

can help it.

Thanks again for your help Mike.

Naru Mangalath

On Nov 8, 10:09 pm, Mike Driscoll kyoso...@gmail.com wrote:

On Nov 8, 12:22 am, Narayanan Mangalath

narayanan.mangal...@gmail.com wrote:

Hi,

I have been trying to incorporate the wxPython mediactrl into a Music

player program in am writng in Python. I am running the program in

Win7 and XP.

I have used the program player_skeleton2.py as a guide to the use of

mediactrl control. I have run this program and it runs fine on Win7

and Xp and plays music fine.

Unfortunately, I have not been able to play any file in my program. I

have assumed that all one needs to do is to define the control, load

the file and play it. It apparently loads the file, but does not play.

I then tried to reproduce the problem by testing my assumption above.

I removed what I thought are the unnecessary bits to reproduce the

problem in the player_skeleton2.py program and tried to run it. It did

not run! Ihave included the program and the output below.

I am sure some crucial step is missing from it. But what? I have been

at it for many hours and still cannot find the missing piece.

I must say that I am rather new to wxPython.

Thanks for any help

Is it just the one file or are there multiple files that won’t play? I

copied most of the code from the wxPython demo. Since writing that

code, I’ve switched to using this mplayer wrapper instead:http://mplayerctrl.dav1d.de/docs/

It seems to work better, although finding the right version of mplayer

on Windows can be a little annoying. If you stick with the default wx

media player, then I recommend looking at the Demo code too. As I

recall, MediaCtrl is kind of fragile.


Mike Driscoll

Blog: http://blog.pythonlibrary.org

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

If you run your application with pythonw.exe, you won’t get that annoying command window.

Thanks Mike.
I installed SMPlayer and the MPlayerCtrl and am able to get a file to
play. I have a couple of further questions on it.

  1. When I run the program (.py file) by double clicking it, it also
    opens a command window for the mplayer.exe. This is very annoying. Is
    there a way for it not to open the command window?

If you just rename the .py file to .pyw then you will normally get rid of the console window.

  1. Is it possible to compile the Pyhton program (py2exe for example)
    so that the I can run it anywhere without the target computer having
    to install the mplayer and the MplayerCtrl?

Almost certainly if you can get the extra files list correct for py2exe but check the licences on mplayer & MplayerCtrl.

···

From: Boštjan Mejak

Sent: Tuesday, November 09, 2010 10:47 AM

To: wxpython-users@googlegroups.com

Subject: Re: [wxPython-users] Re: wxPython mediactrl problem

On Tue, Nov 9, 2010 at 3:06 AM, Narayanan Mangalath narayanan.mangalath@gmail.com wrote:

With pymedia for example, I do not have the above two problems. But
pymedia is not being developed now and I do not want to use it if I
can help it.

Thanks again for your help Mike.

Naru Mangalath

On Nov 8, 10:09 pm, Mike Driscoll kyoso...@gmail.com wrote:

On Nov 8, 12:22 am, Narayanan Mangalath > > > > > > > > <narayanan.mangal...@gmail.com > wrote:

Hi,

I have been trying to incorporate the wxPython mediactrl into a Music
player program in am writng in Python. I am running the program in
Win7 and XP.

I have used the program player_skeleton2.py as a guide to the use of
mediactrl control. I have run this program and it runs fine on Win7
and Xp and plays music fine.

Unfortunately, I have not been able to play any file in my program. I
have assumed that all one needs to do is to define the control, load
the file and play it. It apparently loads the file, but does not play.

I then tried to reproduce the problem by testing my assumption above.
I removed what I thought are the unnecessary bits to reproduce the
problem in the player_skeleton2.py program and tried to run it. It did
not run! Ihave included the program and the output below.

I am sure some crucial step is missing from it. But what? I have been
at it for many hours and still cannot find the missing piece.

I must say that I am rather new to wxPython.

Thanks for any help

Is it just the one file or are there multiple files that won’t play? I
copied most of the code from the wxPython demo. Since writing that
code, I’ve switched to using this mplayer wrapper instead:http://mplayerctrl.dav1d.de/docs/

It seems to work better, although finding the right version of mplayer
on Windows can be a little annoying. If you stick with the default wx
media player, then I recommend looking at the Demo code too. As I
recall, MediaCtrl is kind of fragile.


Mike Driscoll

Blog: http://blog.pythonlibrary.org


To unsubscribe, send email to mailto:wxPython-users%2Bunsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en


To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Thanks Mike.
I installed SMPlayer and the MPlayerCtrl and am able to get a file to
play. I have a couple of further questions on it.

1. When I run the program (.py file) by double clicking it, it also
opens a command window for the mplayer.exe. This is very annoying. Is
there a way for it not to open the command window?

As already mentioned, renaming the extension to pyw should fix this...

2. Is it possible to compile the Pyhton program (py2exe for example)
so that the I can run it anywhere without the target computer having
to install the mplayer and the MplayerCtrl?

The mplayer may need some finessing to distribute it. You might have
to include the installer and let InnoSetup handle it. The MplayerCtrl
is Python, so py2exe should include it automatically.

I've also seen some Python bindings for GStreamer, although I don't
know how well that integrates with wxPython.

···

On Nov 8, 8:06 pm, Narayanan Mangalath <narayanan.mangal...@gmail.com> wrote:

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Thanks to everyone who responded

Naru Mangalath

···

On Nov 9, 10:07 pm, Mike Driscoll <kyoso...@gmail.com> wrote:

On Nov 8, 8:06 pm, Narayanan Mangalath <narayanan.mangal...@gmail.com> > wrote:

> Thanks Mike.
> I installed SMPlayer and the MPlayerCtrl and am able to get a file to
> play. I have a couple of further questions on it.

> 1. When I run the program (.py file) by double clicking it, it also
> opens a command window for the mplayer.exe. This is very annoying. Is
> there a way for it not to open the command window?

As already mentioned, renaming the extension to pyw should fix this...

> 2. Is it possible to compile the Pyhton program (py2exe for example)
> so that the I can run it anywhere without the target computer having
> to install the mplayer and the MplayerCtrl?

The mplayer may need some finessing to distribute it. You might have
to include the installer and let InnoSetup handle it. The MplayerCtrl
is Python, so py2exe should include it automatically.

I've also seen some Python bindings for GStreamer, although I don't
know how well that integrates with wxPython.

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Hello,

···

On Nov 9, 3:06 am, Narayanan Mangalath <narayanan.mangal...@gmail.com> wrote:

1. When I run the program (.py file) by double clicking it, it also
opens a command window for the mplayer.exe. This is very annoying. Is
there a way for it not to open the command window?

This could be also a subprocess "problem", I never had this issue but
I read about it in the german Python-board, if it now works for you
I'll append to the .pyw soloution to the docs, if not, pls open an
issue (http://bitbucket.org/dav1d/mplayerctrl/issues?
status=new&status=open). I've already an idea to fix this.

Dav1d