0

I am using python 2.7 on window and raspberry pi.

I am referring to below given link .

 http://www.blog.pythonlibrary.org/2010/07/24/wxpython-creating-a-simple-media-player/

I can play a single file in MplayerCtrl. But when i try to load a play list file, MplayerCtrl does not respond.

The below given code works.

   self.mplayer = mpc.MplayerCtrl(self.panel, -1, mplayerpath)
   ..
   ..
   ..
   self.mplayer.Loadfile('I:\Outputsync.avi')
   self.playbackTimer.Start(100)
   self.mplayer.Start()  

The other way also work. -

   subprocess.call('mplayer.exe -playlist I:\playlist.txt -shuffle' ,shell=False)

The FutureCall also work. -

  import wx
  import MplayerCtrl as mpc

  class Frame(wx.Frame):
      def __init__(self, parent, id):
          wx.Frame.__init__(self, parent, id)

          self.mpc = mpc.MplayerCtrl(self, -1, u'mplayer.exe')

          #wx.FutureCall(2500, self.mpc.Loadfile, u'Outputsync.avi')
          wx.FutureCall(2500, self.mpc.Loadlist, u'I:/playlist.txt')

          self.Show()

  if __name__ == '__main__':
      app = wx.App(redirect=False)
      f = Frame(None, -1)
      app.MainLoop()

But this code does not work.

   import MplayerCtrl as mpc
   self.mplayer = mpc.MplayerCtrl(self.panel, -1, mplayerpath)
   ..
   ..
   ..
   self.mplayer.Loadlist('I:\playlist.txt',1)
   self.playbackTimer.Start(100)
   self.mplayer.Start()  

This one return 'None'

  import MplayerCtrl as mpc
  def on_add_file(self, event):
         self.mplayer = mpc.MplayerCtrl(self.panel, -1, mplayerpath)
         ..
         ..
         ..
         mpc.MplayerCtrl.Loadlist(self.mplayer,'I:\playlist.txt',1)
         self.playbackTimer.Start(100)
         self.mplayer.Start()

Please give me some hint where i am going wrong.

1 Answers1

0

I got the answer .

unicode prefix was missing before the filename.

 import MplayerCtrl as mpc

 def on_add_file(self, event):     

        self.mplayer = mpc.MplayerCtrl(self.panel, -1, mplayerpath)
        ..
        ..
        ..
        subprocess.call('mplayer.exe -playlist I:\playlist.txt -shuffle' ,shell=False)

        self.mplayer.Loadfile(u'I:/Outputsync.avi')            
        self.mplayer.Loadlist(u'I:/playlist.txt',1)

        mpc.MplayerCtrl.Loadfile(self.mplayer,u'I:/Outputsync.avi')
        mpc.MplayerCtrl.Loadlist(self.mplayer,u'I:/playlist.txt',1)

        wx.FutureCall(1, self.mplayer.Loadlist, u'I:/playlist.txt' , 1)

        self.playbackTimer.Start(100)
        self.mplayer.Start()