Issue #10 resolved

'None' returned with GetProperty (the_prop) 0.3.2

Anonymous created an issue

import wx import MplayerCtrl as mpc import os

PATH = u'C:/Program Files/SMPlayer/mplayer/mplayer.exe' MPLAYERDIR = "C:/Program Files/SMPlayer/mplayer" FILE_DIR = os.path.join(os.path.dirname(os.getcwd()),u'sample_media/Wildlife.wmv') FILE_DIR = FILE_DIR.replace('\','/')

class Frame(wx.Frame): def init(self, parent, id): self.frame = wx.Frame.init(self, parent, id)

    self.mpc1 = mpc.MplayerCtrl(self, -1, PATH)

    #wx.FutureCall(500, self.mpc1.Loadfile,FILE_DIR)
    self.Show()
    self.mpc1.Start()
    self.mpc1.Loadfile(FILE_DIR)


    #self.mpc.SpeedIncr(3)
    #self.mpc.Seek(4)
    print self.mpc1.length
    self.mpc1.SetProperty("speed", 0.78)

    abc = self.mpc1.GetProperty('length')
    print abc





    self.Show()

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

Comments (4)

  1. Anonymous

    Sorry about the code formatting previously.

    import wx
    import MplayerCtrl as mpc
    import os
    
    PATH = u'C:/Program Files/SMPlayer/mplayer/mplayer.exe'
    MPLAYERDIR = "C:/Program Files/SMPlayer/mplayer"
    FILE_DIR = os.path.join(os.path.dirname(os.getcwd()),u'sample_media/Wildlife.wmv')
    FILE_DIR = FILE_DIR.replace('\\','/')
    
    class Frame(wx.Frame):
        def __init__(self, parent, id):
            self.frame = wx.Frame.__init__(self, parent, id)
    
            self.mpc1 = mpc.MplayerCtrl(self, -1, PATH)
    
            #wx.FutureCall(500, self.mpc1.Loadfile,FILE_DIR)
            self.Show()
            self.mpc1.Start()
            self.mpc1.Loadfile(FILE_DIR)
              
           
            print self.mpc1.length
            self.mpc1.SetProperty("speed", 0.78)
            abc = self.mpc1.GetMetaTrack()
            
            print abc #returns 'None'
            print self.frame.mpc1.GetVideoCodec() #returns 'None'
            
            
            
            
    
            self.Show()
    
    if __name__ == '__main__':
        app = wx.App(redirect=False)
        f = Frame(None, -1)
        app.MainLoop()
    
  2. dav1d repo owner

    Not a bug, the media must be started to get the requested information:

    # -*- coding: utf-8 -*-
    
    import wx
    import MplayerCtrl as mpc
    import os
    
    PATH = ur'C:/Program Files/SMPlayer/mplayer/mplayer.exe'
    FILE_DIR = ur'sample_media/Wildlife.wmv'
    
    class Frame(wx.Frame):
        def __init__(self, parent, id):
            self.frame = wx.Frame.__init__(self, parent, id)
    
            self.mpc1 = mpc.MplayerCtrl(self, -1, PATH)
    
            self.Show()
    
            self.mpc1.Start(FILE_DIR)
    
            self.Bind(mpc.EVT_MEDIA_STARTED, self.media_started)
    
        def media_started(self, evt):
            print self.mpc1.length
            self.mpc1.SetProperty('speed', 0.78)
            abc = self.mpc1.GetMetaTrack()
            
            print abc
            print self.mpc1.GetVideoCodec()
    
    
    if __name__ == '__main__':
        app = wx.App(redirect=False)
        f = Frame(None, -1)
        app.MainLoop()
    

    There is nothing I can change, since this is a limitation from MPlayer, what you could do is, pausing the video/file in the EVT_MEDIA_STARTED callback.

  3. vram

    Ok, thank you! works now.

    Another query, upon giving the command:

    self.mpc1.SetProperty('speed', 4)
    

    ...the audio finishes before the video, so the output is not in sync. I used the following command to appear to make it sync:

    self.mpc1.FrameDrop(1.5)
    

    ..is there a better way to make the audio and video output sync together? Am I missing something?(yet again..)

  4. dav1d repo owner

    This is interesting, but definitly a mplayer bug or just bad design. I don't know of a "proper" way to avoid that.

  5. Log in to comment