Hi. Attached you find an attempt to adding MediaCtrl to WxRuby. It''s only tested on windows (compiled with msvc 6.0). Everything seems to be working fine except for a small problem with a few functions: wxFileOffset Seek(wxFileOffset where, wxSeekMode mode = wxFromStart); wxFileOffset Tell(); //FIXME: This should be const wxFileOffset Length(); //FIXME: This should be const wxFileOffset GetDownloadProgress(); // DirectShow only wxFileOffset GetDownloadTotal(); // DirectShow only Wx file offset is typedefed in WxWindows to an int or 64-bit int depending on compiler. In wxMediaCtrl.h I''ve typedeffed it to int witch seems to work but will break for relay huge files on platforms that supports it (windows and ?). Have anyone bumped into this before? It would be possible to omit these functions but seek, tell and length are quite usable. MediaCtrl.rb is a port of the WxPython sample demonstrating some of the functionality. This is my first real attempt at hacking wxruby, so I might have done something terribly wrong... Alex warned me on wxruby-users that the underlaying inheritence-chain made wrapping difficult - perhaps I wasn''t looking hard enough but I found it quite straight forward. The wxMediaBackend class is not wrapped though - I can''t see a reason to code media backends in ruby... ;-) -Albin Holmgren -------------- next part -------------- A non-text attachment was scrubbed... Name: Event.i.diff Type: application/octet-stream Size: 730 bytes Desc: not available Url : http://rubyforge.org/pipermail/wxruby-development/attachments/20071121/cb772a79/attachment-0004.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: evthandler.rb.diff Type: application/octet-stream Size: 798 bytes Desc: not available Url : http://rubyforge.org/pipermail/wxruby-development/attachments/20071121/cb772a79/attachment-0005.obj -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: MediaCtrl.i Url: http://rubyforge.org/pipermail/wxruby-development/attachments/20071121/cb772a79/attachment-0002.pl -------------- next part -------------- A non-text attachment was scrubbed... Name: MediaCtrl.rb Type: application/octet-stream Size: 3796 bytes Desc: not available Url : http://rubyforge.org/pipermail/wxruby-development/attachments/20071121/cb772a79/attachment-0006.obj -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: MediaEvent.i Url: http://rubyforge.org/pipermail/wxruby-development/attachments/20071121/cb772a79/attachment-0003.pl -------------- next part -------------- A non-text attachment was scrubbed... Name: parents.rb.diff Type: application/octet-stream Size: 585 bytes Desc: not available Url : http://rubyforge.org/pipermail/wxruby-development/attachments/20071121/cb772a79/attachment-0007.obj -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: wxMediaCtrl.h Url: http://rubyforge.org/pipermail/wxruby-development/attachments/20071121/cb772a79/attachment-0002.h -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: wxMediaEvent.h Url: http://rubyforge.org/pipermail/wxruby-development/attachments/20071121/cb772a79/attachment-0003.h
Hi Albin Albin Holmgren wrote:> Attached you find an attempt to adding MediaCtrl to WxRuby. It''s only > tested on windows (compiled with msvc 6.0). >Great work. I will have a go with this on GTK next. This will be a valuable addition.> Everything seems to be working fine except for a small problem with a > few functions: > > wxFileOffset Seek(wxFileOffset where, wxSeekMode mode = wxFromStart); > wxFileOffset Tell(); //FIXME: This should be const > wxFileOffset Length(); //FIXME: This should be const > wxFileOffset GetDownloadProgress(); // DirectShow only > wxFileOffset GetDownloadTotal(); // DirectShow only > > Wx file offset is typedefed in WxWindows to an int or 64-bit int > depending on compiler. In wxMediaCtrl.h I''ve typedeffed it to int > witch seems to work but will break for relay huge files on platforms > that supports it (windows and ?). Have anyone bumped into this before? > It would be possible to omit these functions but seek, tell and length > are quite usable. >I think these functions are important and should be included. But int seems a short type for this purpose, since IIRC it''s counting milliseconds. It''s OK to have compiler/platform-specific typedefs (with ifdef) in swig files if this would help.> MediaCtrl.rb is a port of the WxPython sample demonstrating some of > the functionality. >Cool.> The > wxMediaBackend class is not wrapped though - I can''t see a reason to > code media backends in ruby... ;-) >I agree - we''ve gone the same with some of the other backend classes (Renderer, GraphicsRenderer) that don''t seem useful in wxRuby. cheers alex
Albin Holmgren wrote:> Attached you find an attempt to adding MediaCtrl to WxRuby. It''s only > tested on windows (compiled with msvc 6.0).I''ve just committed this to SVN. Worked nicely; very pleasing to code an MP3 player app in less than 200 lines of Ruby. The only tricky bit is getting wxGTK to compile with support for MediaCtrl. It requires quite a few extra Ubuntu packages to be installed. So I''m going to look for a way to test if MediaCtrl is supported, and if not, skip it in the rakefile, as we do with Scintilla - otherwise, it''ll make compiling wxRuby on Linux a bit fiddly. I also played around a bit with the sample to make some cosmetic changes (eg showing the time elapsed and length in minutes and seconds), and to add some comments on what''s going on. More generally, I''m wondering if we should create a "wxruby-lite" package that excludes some of the more specialist controls like MediaCtrl, Scintilla, Grid, AUI, HtmlCtrl etc. Would people be interested in something that would make substantially smaller binaries when used with eg rubyscript2exe? Thanks again alex
Alex Fenton wrote:> More generally, I''m wondering if we should create a "wxruby-lite" > package that excludes some of the more specialist controls like > MediaCtrl, Scintilla, Grid, AUI, HtmlCtrl etc. Would people be > interested in something that would make substantially smaller binaries > when used with eg rubyscript2exe?Although it''s quite similar to your suggestion, I like the approach described in the roadmap better (the "Modularise the library so not everything is compiled into a single .so file." thing): http://wxruby.rubyforge.org/wiki/wiki.pl?DevelopmentRoadmap Best regards, Jari Williamsson
The only tricky bit is getting wxGTK to compile with support for> MediaCtrl. It requires quite a few extra Ubuntu packages to be > installed. So I''m going to look for a way to test if MediaCtrl is > supported, and if not, skip it in the rakefile, as we do with Scintilla > - otherwise, it''ll make compiling wxRuby on Linux a bit fiddly.I had similar trouble with the Graphics.* classes (added recently, I belive). Those are not enabled by default on windows and wxWidgets 2.8.6 (although recommended in msw/setup.h) Perhaps a similar check could be done to see if wxUSE_GRAPHICS_CONTEXT is enabled and if not disable those. One more thing, I think the typedeffed wxFileOffset could be better handled with a swig typemap. I''m still trying to grok this about this, but it seems like the right way to do it - I''ll try to find time to fix this in next few days. -Albin Holmgren -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-development/attachments/20071122/2c02df85/attachment.html
Albin Holmgren wrote:> I had similar trouble with the Graphics.* classes (added recently, I > belive). > Those are not enabled by default on windows and wxWidgets 2.8.6 > (although recommended in msw/setup.h) > Perhaps a similar check could be done to see if wxUSE_GRAPHICS_CONTEXT > is enabled and if not disable those.Yes, I had to do the same fiddling about on Windows having added them on Linux initially; I''d like to do the same checking because they''re quite specialised in purpose.> One more thing, I think the typedeffed wxFileOffset could be better > handled with a swig typemap. I''m still trying to grok this about this, > but it seems like the right way to do it - I''ll try to find time to > fix this in next few days.OK, it seems more like a typedef than a typemap to me, but perhaps there''s something clever to be done to make it work better. I haven''t run into any troubles yet with mp3s that are two hours long. There''s some tidying up (additional docs and samples for new classes) to be done so we won''t be releasing for another week or two yet. alex
Jari Williamsson wrote:> Alex Fenton wrote: > > >> More generally, I''m wondering if we should create a "wxruby-lite" >> package that excludes some of the more specialist controls like >> MediaCtrl, Scintilla, Grid, AUI, HtmlCtrl etc. Would people be >> interested in something that would make substantially smaller binaries >> when used with eg rubyscript2exe? >> > > Although it''s quite similar to your suggestion, I like the approach > described in the roadmap better (the "Modularise the library so not > everything is compiled into a single .so file." thing): > http://wxruby.rubyforge.org/wiki/wiki.pl?DevelopmentRoadmap >So do I :) But doing a "wxruby-lite" is probably easier as an interim. We can use the "$excluded_classes" variable in the rakefiles just to skip particular classes from a build, but it would still be a single .so. We''d still have to move some of the event type mappings from evthandler.rb into the appropriate class files (eg grid.rb). Which is a step in the right direction. To break it up into multiple .so files is more tricky, because we''d have to replicate the module initialisation code which is in wx.cpp. This predates my involvement with wxRuby and it''s one of those "leave well enough alone" bits that I don''t properly understand. Unless someone else really wants to get their heads round this, it seems a bit disruptive at this point. cheers alex