Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946
Where to put game sound files?
I am developing a game and dont know where to put the sound files. If i put it hardcoded in a path, then there is a problem for the installation file. Also, If i put it in the resources, QT does not play wave files from resources also all those files are loaded into memory. Now i am developing for MAC, in mac there is a folder for my applicatin.app and inside it there should be the sound files.
But what would be the path of the sound file at run time? and how to put the sound files inside the app folder while programming and testing?
For windows, i can locate it at the same installation folder with ex ./resource/media.wav
Could any body help me please for Mac
The 'Resources' folder in your app bundle should do fine. "https://developer.apple.com/library/mac/#documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html":https://developer.apple.com/library/mac/#documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html
AFAIK you need to copy them in your .PRO file (from wherever they are to the bundle).
but how to put them in the resources of my bundle
I am sure there are other ways but this worked for me:
QMAKE_POST_LINK = mkdir -p $$TARGET".app/Contents/Resources" && cp -Rf $$PWD/folder_with_soundfiles_in_you_sourcedirectoty $$OUT_PWD/$$TARGET".app/Contents/Resources"
what is QMAKE? is it a command to be written inside the pro file?
is it only for deployment or also debugging while development?
matti- last edited by
Specify your media files to deploy with something like:
mediafolder.source = data/media
DEPLOYMENTFOLDERS = mediafolder
Then, at runtime, use QCoreApplication::applicationDirPath() to find your executable's directory and form an absolute path to your media/ directory from that.
This is what we're doing in our main.cpp for a QtQuick 2.0 project (applies to non-QML project as well):
QString appdir = QCoreApplication::applicationDirPath();
qDebug() << "application dir is " << appdir;
QString filePrefix = "file://" + appdir + "/../Resources/";
QString filePrefix = "file:///" + appdir + "/";
qDebug() << "filePrefix is " << filePrefix;
Then in QML code we use it as such:
source: filePrefix + "media/theme.m4a"
and in the .pro file we have the macro definitions:
win32:DEFINES += WINDOWS_BUILD
macx:DEFINES += MACOSX_BUILD
I find it very irritating that media play does not work from a qrc resource. I tried fooling around for an hour with memory-based QIODevice solutions with QMediaPlayer but could not make it work in that timeframe.
thank you the details but i can not get it to work properly.
For testing, i made the following :-
In the Pro file I added
myFiles.sources = *
myFiles.path = /Volumes/DATA/gamemedia/
DEPLOYMENT += myFiles
then I compile the application from the Creator. I then open Terminal in MAC and get inside the application.app file, and then the Resources folder and don't find the files in it
Is there something missing?
Is it Deployment or Deploymentfolders?
If you look in the qmake Variable reference, under DEPLOYMENT: it reads
bq. This is only used on Windows CE and the Symbian platform.
That doesn't solve your problem, but you should definitely not use DEPLOYMENT on a Mac. Sadly DEPLOYMENTFOLDERS is not even mentioned in the reference :-/