Active Topics

 


Reply
Thread Tools
Posts: 60 | Thanked: 23 times | Joined on Jan 2010
#1
I got this bit of code that I run on a N900 with PR1.3 Qt4.7 Mobility 1.0.2

Code:
QMediaPlayer *player = new QMediaPlayer;
player->setMedia(QUrl::fromLocalFile("ballhit.wav"));
player->setVolume(50);
player->play();


When I run it, this happends:

GStreamer; Unable to play – “file:ballhit.wav”

I think that it may not find the file, I have tried many different methods of adding the wav file to my project, but none seems to work, I don’t know what is the best approach.
If i replace “ballhit.wav” with for example: ”Http://tst.com/b.wav”, it works, no problem.
But I can’t load my sound files from the web, I want them on the device.

Developing on windows with Qt Creator.

Please help me
 
Posts: 200 | Thanked: 44 times | Joined on Jan 2010
#2
have you tryed adding it to the qrc file. im no expert but i do that with all my graphics befor i load them. This i think imbeds them in the executable tho which means its not optifyed. so before uploading to extras or testing you will have to work out how to load them from file and add them to the opt folder for your app.

What i know is in a browser you would use file:// to access a local file instead of a remote webservers file.

but if i am loading a image from file in qt i would pass the string ":sprites/image.png"

sprites being the folder in the src directory that holds the images.

image.png being the image in the folder.

for you this would be something like ":sounds/sounds1.wav"

or maybe "file://sounds/sound1.wav"

Last edited by jamie721; 2010-10-28 at 21:27.
 

The Following User Says Thank You to jamie721 For This Useful Post:
Posts: 60 | Thanked: 23 times | Joined on Jan 2010
#3
Thank you, I have tried to add the file to my resource file, and also tried all your suggestions, but it still does not work.
 
Posts: 1,048 | Thanked: 979 times | Joined on Mar 2008 @ SF Bay Area
#4
Originally Posted by tmsha View Post
I got this bit of code that I run on a N900 with PR1.3 Qt4.7 Mobility 1.0.2

Code:
QMediaPlayer *player = new QMediaPlayer;
player->setMedia(QUrl::fromLocalFile("ballhit.wav"));
player->setVolume(50);
player->play();


When I run it, this happends:

GStreamer; Unable to play – “file:ballhit.wav”

I think that it may not find the file, I have tried many different methods of adding the wav file to my project, but none seems to work, I don’t know what is the best approach.
If i replace “ballhit.wav” with for example: ”Http://tst.com/b.wav”, it works, no problem.
But I can’t load my sound files from the web, I want them on the device.

Developing on windows with Qt Creator.

Please help me
I had this problem, and the only way I could fix it was to do the following:
Code:
QFileInfo info (path);
if (!info.exists ()) {
    // error out
}
QString strFullname = info.absoluteFilePath ();
player.setMedia (QUrl::fromLocalFile(strFullname));
__________________
qgvdial: Google Voice client. All downloads
qgvtp: Phone integration for the n900 that dials out and sends texts using qgvdial.
mosquitto: message broker that implements the MQ Telemetry Transport protocol version 3.
qgvnotify: Google voice and contacts notifier for diablo and maemo.

If you want to thank me, click the Thanks button.
If you'd like to thank my applications, vote to move them to extras.
 

The Following User Says Thank You to uvatbc For This Useful Post:
Posts: 60 | Thanked: 23 times | Joined on Jan 2010
#5
thank you I will try it
 
Posts: 60 | Thanked: 23 times | Joined on Jan 2010
#6
I did the following:

Code:
QFileInfo info("ballhit.wav");
QString strFullname = info.absoluteFilePath ();
QMediaPlayer *player = new QMediaPlayer;
player->setMedia(QUrl::fromLocalFile(strFullname));
It does not work...
info.exists()
and
info.isFile()
both returns false...

How did you include your file with the project?
 
Posts: 1,048 | Thanked: 979 times | Joined on Mar 2008 @ SF Bay Area
#7
Originally Posted by tmsha View Post
I did the following:

Code:
QFileInfo info("ballhit.wav");
QString strFullname = info.absoluteFilePath ();
QMediaPlayer *player = new QMediaPlayer;
player->setMedia(QUrl::fromLocalFile(strFullname));
It does not work...
info.exists()
and
info.isFile()
both returns false...

How did you include your file with the project?
Where is ballhit.wav with respect to your executable binary?
Is it in the same directory? Then try "./ballhit.wav"

Use QFileInfo::exists to find out if your executable binary exists where you think it does. How do you execute your app? Do you do it from the same directory as the wave file?
The "." in "./ballhit.wav" typically means "current directory" which is the directory in which you started running your app.

Edit:
Also: My media files are generated on the fly. So my case isn't exactly like yours.
__________________
qgvdial: Google Voice client. All downloads
qgvtp: Phone integration for the n900 that dials out and sends texts using qgvdial.
mosquitto: message broker that implements the MQ Telemetry Transport protocol version 3.
qgvnotify: Google voice and contacts notifier for diablo and maemo.

If you want to thank me, click the Thanks button.
If you'd like to thank my applications, vote to move them to extras.
 

The Following User Says Thank You to uvatbc For This Useful Post:
Posts: 60 | Thanked: 23 times | Joined on Jan 2010
#8
Thank you for your replay.

I have found the path of the executable to be: ”/usr/local/bin/” but there is no “ballhit.wav” in that dir.

I can go to that dir and do ./app and it runs like normal, but the sounds does not work.


I did a “find . -name “ballhit.wav”” with root and found nothing on the phone.
So, the file has not been copied ?
How can I ensure the file is copied and installed with the executable?
I think that is my problem.. I need to copy the file over to the phone when i run it from Qt Creator.

I have done the following in an attempt to fix it:

In the same folder as src.pro i got ballhit.wav, and in src.pro i added this:

OTHER_FILES += ballhit.wav

target.path = $$DESTDIR
target.files += ballhit.wav
INSTALLS += target

I have also added a build step: “make install”

Last edited by tmsha; 2010-10-28 at 23:23.
 
Posts: 1,048 | Thanked: 979 times | Joined on Mar 2008 @ SF Bay Area
#9
Originally Posted by tmsha View Post
Thank you for your replay.

I have found the path of the executable to be: ”/usr/local/bin/” but there is no “ballhit.wav” in that dir.

I can go to that dir and do ./app and it runs like normal, but the sounds does not work.


I did a “find . -name “ballhit.wav”” with root and found nothing on the phone.
So, the file has not been copied ?
How can I ensure the file is copied and installed with the executable?
I think that is my problem.. I need to copy the file over to the phone when i run it from Qt Creator.

I have done the following in an attempt to fix it:

In the same folder as src.pro i got ballhit.wav, and in src.pro i added this:

OTHER_FILES += ballhit.wav

target.path = $$DESTDIR
target.files += ballhit.wav
INSTALLS += target

I have also added a build step: “make install”
See my pro file line 173 onwards.

"target" is a tag for your executable binary.
Any additional files that you want installed need to come with additional tags. In my pro file, these additional tags for my maemo5 binary are "desktop" "icon" "qss" etc.

After defining that INSTALLS needs to have extra tags, I also specified where the files in every tag should fall (tag.path) and what the source file is on my dev machine (tag.files).

Once you do all that, your deb should have everything you need.
Also: once you actually build your deb, its a good idea to go into the debian sub directory and see the directory structure in there to confirm that the deb-helpers have done what you wanted.

Remember that a deb is a compressed archive of:
1. All the files you said need to be installed (binary, media files, whatever else)
2. Control scripts to pick up things from a deb and put them into the correct corresponding locations on the user machine
3. Dependency and other meta information
__________________
qgvdial: Google Voice client. All downloads
qgvtp: Phone integration for the n900 that dials out and sends texts using qgvdial.
mosquitto: message broker that implements the MQ Telemetry Transport protocol version 3.
qgvnotify: Google voice and contacts notifier for diablo and maemo.

If you want to thank me, click the Thanks button.
If you'd like to thank my applications, vote to move them to extras.
 

The Following User Says Thank You to uvatbc For This Useful Post:
Posts: 60 | Thanked: 23 times | Joined on Jan 2010
#10
Thank you so much! That is exactly what I was looking for (I think).
I remember using code like that in my pro file when I was working on scratchbox
I will try it out now!
 
Reply


 
Forum Jump


All times are GMT. The time now is 00:42.