PDA

View Full Version : Phonon and Ruby



t1m
January 3rd, 2008, 11:39 PM
I recently did this (http://techbase.kde.org/Development/Tutorials/Qt4_Ruby_Tutorial) Qt/Ruby tutorial on the Kde TechBase.

I've been trying to make a multimedia player using ruby, and I would like to be using Phonon. It's been a bit confusing, and I haven't been able to get it to play any sound or anything (!).

When I try running this: (tranlated from this wikipedia page (http://en.wikipedia.org/wiki/Phonon_(KDE)))


require 'korundum4'
require 'Qt4'

media = MediaObject.new(self)
Qt::Object.connect(media, SIGNAL('finished()'), SLOT('slotFinished()'))
media.setCurrentSource("/home/kde-devel/ruby/oops.mp3")
media.play()
I get:

ruby/test5.rb:4: uninitialized constant MediaObject (NameError)
What's wrong?

Any help would be much appreciated.

Thanks. :KS

nathandelane
January 4th, 2008, 08:27 PM
The problem is that MediaObject must be part of some module that you're not including, like Qt.

Try:

media = Qt::MediaObject.new(self)

Nathan

nathandelane
January 4th, 2008, 08:40 PM
Take a look at this page: http://phonon.kde.org/cms/1022. It looks like I'm wrong too:

MediaObject::MediaObject.new(self) might work.

I think that because of this #include <Phonon/MediaObject> on this page http://api.kde.org/4.0-api/kdelibs-apidocs/phonon/html/classPhonon_1_1MediaObject.html

Nathan

t1m
January 7th, 2008, 04:52 PM
Thanks Nathan. Please forgive my slowness, I have been quite bussy.

I tried your ideas--still not working. Hmmmmm. I think I'll try looking in some more places........

frogface
August 24th, 2009, 01:10 PM
My understanding is that to use the VideoPlayer class (I'm using Qt version 4.5.0) you would use the following code



require 'Qt'
require 'phonon'

Phonon::VideoPlayer


In other words, you would prefix with Phonon:: to access the VideoPlayer class.

I would image that's the same for MediaObject. So perhaps Phonon::MediaObject.new(self) would work.

t1m
August 24th, 2009, 11:41 PM
Thanks for the reply, but I have ended the project. (Note how old this thread is.) It may have been also that Phonon/KDE4 was still very new when I tried this.

But thank you anyway.