Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Where to put game sound files?
Forum Updated to NodeBB v4.3 + New Features

Where to put game sound files?

Scheduled Pinned Locked Moved Game Development
8 Posts 3 Posters 4.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SherifOmran
    wrote on last edited by
    #1

    Hello guys,

    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

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hardcodes.de
      wrote on last edited by
      #2

      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).

      while(!sleep){++sheep;}

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SherifOmran
        wrote on last edited by
        #3

        but how to put them in the resources of my bundle

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hardcodes.de
          wrote on last edited by
          #4

          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"
          @

          while(!sleep){++sheep;}

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SherifOmran
            wrote on last edited by
            #5

            what is QMAKE? is it a command to be written inside the pro file?
            is it only for deployment or also debugging while development?

            1 Reply Last reply
            0
            • M Offline
              M Offline
              matti-
              wrote on last edited by
              #6

              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;

              #if defined(MACOSX_BUILD)
              QString filePrefix = "file://" + appdir + "/../Resources/";
              #elif defined(WINDOWS_BUILD)
              QString filePrefix = "file:///" + appdir + "/";
              #endif
              qDebug() << "filePrefix is " << filePrefix;
              @

              Then in QML code we use it as such:

              @
              Audio {
              id: defaultMusic
              source: filePrefix + "media/theme.m4a"
              autoPlay: true
              loops: Audio.Infinite
              volume: 1.0
              }
              @

              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.

              • Matti

              Author of <a href="http://mmark.777-team.org/">MMark13</a>

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SherifOmran
                wrote on last edited by
                #7

                Hello Matti

                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?
                http://www.developer.nokia.com/Community/Wiki/Using_the_DEPLOYMENT_keyword_in_a_Qt_package_file

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  hardcodes.de
                  wrote on last edited by
                  #8

                  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 :-/

                  while(!sleep){++sheep;}

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved