wx.media resize video

179 views
Skip to first unread message

kevjwells

unread,
May 26, 2016, 2:51:43 PM5/26/16
to wxPython-users
Hi, I am using wx.media to play video files which are quite small and wondered if there was a way to resize the video to make it bigger?
I am using the MediaCtrl.py from the Wxpython Demo. What would I need to add where to resize the video please?

Kind regards.

David Woods

unread,
May 26, 2016, 3:44:36 PM5/26/16
to wxpytho...@googlegroups.com
I use wxMediaCtrl inside a Sizer and I think the Sizer just handles it all. 

David


Hi, I am using wx.media to play video files which are quite small and wondered if there was a way to resize the video to make it bigger?
I am using the MediaCtrl.py from the Wxpython Demo. What would I need to add where to resize the video please?

Kind regards.
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

kevjwells

unread,
May 27, 2016, 1:23:58 AM5/27/16
to wxPython-users
Hi David, I can now get it to resize, but the when the video resizes it loose its aspect ratio (proportional size). I have tried using wx.SHAPED but this doesn't seem to keep the original shape. I am on Mac, Python 2.7.11. Here is what I currently have, what am I doing wrong?

import wx
import wx.media
import os


class TestPanel(wx.Panel):
   
def __init__(self, parent, log):
       
self.log = log
        wx
.Panel.__init__(self, parent, -1)

       
try:
           
self.mc = wx.media.MediaCtrl(self, style=wx.SIMPLE_BORDER)
       
except NotImplementedError:
           
self.Destroy()
           
raise

        sizer
= wx.StaticBoxSizer(wx.StaticBox(self),wx.HORIZONTAL)
        sizer
.Add(self.mc, wx.SHAPED)
       
self.SetSizer(sizer)
        wx
.CallAfter(self.DoLoadFile, os.path.abspath("Video_683x384.mp4"))
       
self.mc.ShowPlayerControls()

   
def DoLoadFile(self, path):
       
if not self.mc.Load(path):
            wx
.MessageBox("Unable to load %s: Unsupported format?" % path,
                         
"ERROR",
                          wx
.ICON_ERROR | wx.OK)
       
else:
           
self.mc.SetInitialSize()
           
self.GetSizer().Layout()

app
= wx.App()
frame
= wx.Frame(None, -1, "TestPanel", size = (735, 473))
TestPanel(frame, -1)
frame
.Show(1)
app
.MainLoop()

Marcos del Amo

unread,
May 27, 2016, 2:06:50 AM5/27/16
to wxPython-users
Here you have an example of how to make a videoplayer with mediaControl: http://www.blog.pythonlibrary.org/2010/07/24/wxpython-creating-a-simple-media-player/
If you have the MediaPlayer properrly configured you should be able to execute the code (at least one of them If I'm not mistaken) without any issues

I usually use vlc bindings to make my work and with vlc I put the vlc Instance inside a BoxSizer in order to add the controls of the video and some menus.

Hope it helps

kevjwells

unread,
May 27, 2016, 2:51:59 PM5/27/16
to wxPython-users
Hi, I sorted out the aspect ratio for wxMediaCtrl, I just needed to use wx.SHAPED.
Marcos, I tried using VLC, but couldn't get it working, read my post below:

Patrick Maher

unread,
May 29, 2016, 9:13:18 AM5/29/16
to wxPython-users
I put the size in the MediaCtrl command, e.g.:

self.player = wx.media.MediaCtrl(self,-1,size=(588,448))

This works for me. I see that in your example you didn't specify the size.

Patrick
Reply all
Reply to author
Forward
0 new messages