Active Topics

 


Reply
Thread Tools
crabsody's Avatar
Posts: 63 | Thanked: 12 times | Joined on Feb 2010 @ Thessaloniki Greece
#1
Well I just want to play an mp3 sound. Simple as that. So I read in the documentation how to do it. I wrote the following code..

QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
qDebug() << "Device name" << info.deviceName() << endl;

But when I run it to my N900 nothing is printed on the screen!!!
Can somebody help me with this?
 

The Following User Says Thank You to crabsody For This Useful Post:
laasonen's Avatar
Posts: 565 | Thanked: 618 times | Joined on Jun 2010 @ Finland
#2
 
crabsody's Avatar
Posts: 63 | Thanked: 12 times | Joined on Feb 2010 @ Thessaloniki Greece
#3
As I see the developer of the example issues tha command defaultOutputDevice too. Like me. But (in my case) this returns null!!! I have just compiled my code using qt creator and adding MOBILITY += multimedia to the .pro file. When I run it using Simulator then defaultOutputDevice returns something. The same for availableCodecs and so. But when I run the maemo target using my N900 I get nothing....
 
laasonen's Avatar
Posts: 565 | Thanked: 618 times | Joined on Jun 2010 @ Finland
#4
Maybe you should try phonon.
 
crabsody's Avatar
Posts: 63 | Thanked: 12 times | Joined on Feb 2010 @ Thessaloniki Greece
#5
can mafw help?
 
Posts: 1,086 | Thanked: 2,964 times | Joined on Jan 2010
#6
Originally Posted by crabsody View Post
can mafw help?
I have a tutorial about playing sounds in PyQt in my signature ('Build your own Fart App.. in 30 mins'), you can learn a lot about the basics of playing sounds with Phonon from it. I use almost exactly the same code in C++ with mFakeCaller.

For example, here's the startRingtone method Ive written for mFakeCaller:

Code:
    
void startRingtone(const QString &tonePath){
        ringTonePath = tonePath;
        mediaObject = new Phonon::MediaObject(this);
        Phonon::AudioOutput *audioOutput =
        new Phonon::AudioOutput(Phonon::MusicCategory, this);
        Phonon::Path path = Phonon::createPath(mediaObject, audioOutput);
        mediaObject->setCurrentSource(Phonon::MediaSource(tonePath));
        mediaObject->play();
        connect(mediaObject, SIGNAL(finished()), this, SLOT(repeatRingTone()));
    }
It'll play mp3s, wavs, anything Phonon can play.

Ive also created project files to help someone before on another thread. Simply replace the animal sound files with a mp3 file



(Edit: bah looking at that thread again, 42 people downloaded that project and not one person thanked me for making it.. bleeeeeeh )
__________________
Follow me on my neglected twitter @kojacker

Cybot950 - Control a robot with your N9/N950
SMSPetFeeder - Build a Bluetooth/SMS dog feeder with Qt, N950, and arduino
Nerf950 - Use your N9/N950 to fire a Nerf gun

Last edited by kojacker; 2011-02-04 at 19:26.
 

The Following 2 Users Say Thank You to kojacker For This Useful Post:
crabsody's Avatar
Posts: 63 | Thanked: 12 times | Joined on Feb 2010 @ Thessaloniki Greece
#7
Thans Kojacker. I will check this out.
 

The Following User Says Thank You to crabsody For This Useful Post:
crabsody's Avatar
Posts: 63 | Thanked: 12 times | Joined on Feb 2010 @ Thessaloniki Greece
#8
Κojacker one more question. Why your wav files are not in the qrc files? I try to play some mp3 files which I have added to qrc but they don't play...
 
Posts: 1,086 | Thanked: 2,964 times | Joined on Jan 2010
#9
Originally Posted by crabsody View Post
Κojacker one more question. Why your wav files are not in the qrc files? I try to play some mp3 files which I have added to qrc but they don't play...
The only reason was because i wanted people to be able to easily replace them, inc if they didnt have Qt Creator. I think they should still play when added in the qrc resource file if it's linked correctly though.. Try running your application from Xterm and see if it's reporting any error message, ie are you getting a file not found error or something else when it tries to load the sound file?
__________________
Follow me on my neglected twitter @kojacker

Cybot950 - Control a robot with your N9/N950
SMSPetFeeder - Build a Bluetooth/SMS dog feeder with Qt, N950, and arduino
Nerf950 - Use your N9/N950 to fire a Nerf gun
 
crabsody's Avatar
Posts: 63 | Thanked: 12 times | Joined on Feb 2010 @ Thessaloniki Greece
#10
No. I found no errors. If I use this line

mediaObject->setCurrentSource(Phonon::MediaSource(":new/images/images/cow.mp3"))

it doesn't work

if I use this

mediaObject->setCurrentSource(Phonon::MediaSource("/home/grizos/NokiaQtSDK/Projects/Babytoy/music/cow.mp3"));

It works ok.!!!!

Very strange!! ??
 
Reply


 
Forum Jump


All times are GMT. The time now is 19:13.