Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. play audio from QML in iOS
Forum Updated to NodeBB v4.3 + New Features

play audio from QML in iOS

Scheduled Pinned Locked Moved Mobile and Embedded
14 Posts 3 Posters 4.4k Views 3 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.
  • M Offline
    M Offline
    m_andrej
    wrote on last edited by m_andrej
    #1

    There is already a couple of threads on this, but I still can't get it to work. My code looks like this:

    Audio {
        id: music
        source: "italy.mp3"
        autoPlay: true
        loops: Audio.Infinite
        onError: {
            console.log("Audio error: " + errorString)
            console.log("Error code: " + error)
        }
    }
    

    I'm getting no sound and the following output:
    qml: Audio error: Failed to load media
    qml: Error code: 2
    The value 2 means unsupported format, but I get this code also when I try to play .ogg file or enter non-existent file name.
    Of course I'm bundling data directly into the iOS app bundle and not Qt resource file. I inserted QDir().entryList(); into code, which confirms that italy.mp3 is really present in current directory.
    I also tried to import plugins qtaudio_coreaudio qtmedia_audioengine qavfcamera qavfmediaplayer in my *.pro file (although this should not be necessary in Qt 5.4), but no luck.
    Any ideas?

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      zabaat
      wrote on last edited by
      #2

      I am having this same problem too, did you find a resolution?

      M 1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by SGaist
        #3

        Hi and welcome to devnet,

        You can find information on these wiki entries here and there

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        Z 1 Reply Last reply
        0
        • Z Offline
          Z Offline
          zabaat
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • SGaistS SGaist

            Hi and welcome to devnet,

            You can find information on these wiki entries here and there

            Z Offline
            Z Offline
            zabaat
            wrote on last edited by zabaat
            #5

            @SGaist
            I was getting this problem all last night and now today too when accessing those sites:

            Sorry! This site is experiencing technical difficulties.
            Try waiting a few minutes and reloading.

            (Cannot contact the database server)

            Yeah, site 1 from what I can tell asks me to add

            • QTPLUGIN: qtaudio_coreaudio to my .pro file

            which gives me:
            :-1: warning: Redundant entries in QTPLUGIN: qtaudio_coreaudio
            (which makes sense because it says that was an old bug and is automatically added now)

            this is the cache page I'm looking at:
            http://webcache.googleusercontent.com/search?q=cache:MTQX4cjxWbMJ:wiki.qt.io/QtMultimedia_iOS+&cd=1&hl=en&ct=clnk&gl=us
            maybe let me know if i've got some sort of problem if you can access that page

            I'll check out the second site more now that I am a little more fresh, however I found that last night as well and I already include that. We shall see!

            • my deleted comment referred to this guy. his github doesn't seem to address the problem at all..
              https://github.com/niqt/iosqt
              and if you look him up here on the forums you get : https://forum.qt.io/topic/36470/solved-ios-audio/6
              which the last post shares my problem. haha, and the same guy who started this topic is the last post there, did not see that!
            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Seems there was a problem on the backend side of the wiki, but the pages are back today

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • Z zabaat

                I am having this same problem too, did you find a resolution?

                M Offline
                M Offline
                m_andrej
                wrote on last edited by
                #7

                @zabaat No, I didn't. It just doesn't work. I ended up writing platform-specific audio code in Objective-C.

                Z 1 Reply Last reply
                1
                • M m_andrej

                  @zabaat No, I didn't. It just doesn't work. I ended up writing platform-specific audio code in Objective-C.

                  Z Offline
                  Z Offline
                  zabaat
                  wrote on last edited by
                  #8

                  @m_andrej ... Madness! I do not have the skill to do that sadly. Is your work available for purchase or were you planning on releasing it at some point per chance? We just wanted to be able to port our game to iOS (https://play.google.com/store/apps/details?id=oolamba.com.zeusIsAngry) And had a couple other little ones planned, so this is a sad development for us.

                  If not sharing/ selling your direct code could you perhaps link some pointers or something we should look into?

                  Thanks!

                  M 1 Reply Last reply
                  0
                  • Z zabaat

                    @m_andrej ... Madness! I do not have the skill to do that sadly. Is your work available for purchase or were you planning on releasing it at some point per chance? We just wanted to be able to port our game to iOS (https://play.google.com/store/apps/details?id=oolamba.com.zeusIsAngry) And had a couple other little ones planned, so this is a sad development for us.

                    If not sharing/ selling your direct code could you perhaps link some pointers or something we should look into?

                    Thanks!

                    M Offline
                    M Offline
                    m_andrej
                    wrote on last edited by m_andrej
                    #9

                    @zabaat Here is my Qt Quick app where I'm playing sounds:
                    https://itunes.apple.com/cz/app/id1007166471
                    If you rate my app, I will share the code :-)

                    Z 1 Reply Last reply
                    1
                    • M m_andrej

                      @zabaat Here is my Qt Quick app where I'm playing sounds:
                      https://itunes.apple.com/cz/app/id1007166471
                      If you rate my app, I will share the code :-)

                      Z Offline
                      Z Offline
                      zabaat
                      wrote on last edited by
                      #10

                      @m_andrej
                      done!
                      I actually liked it pretty well too. I did experience a small bug, I got NaN in the exploding red text for my score on my first word in one game. I was not able to replicate again though. Also the word JAY gave me ~176 points, not sure if that was intended as the other words were much lower. It was also when I only had 4 squares on the screen at the time.

                      A couple small suggestions if I may,

                      • it would be really nice to have some sort of 'clear selection' and maybe even an 'undo' button, as it's hard to deselect (at least on my iPhone 4s)
                      • a thin line or mark on the side to indicate the danger height, I kept thinking I had more room.

                      other than that very solid, and I did very much like having the whole board open to me and not being limited to just adjacent letters.

                      M 1 Reply Last reply
                      1
                      • M Offline
                        M Offline
                        m_andrej
                        wrote on last edited by
                        #11

                        @zabaat Thanks a lot! I will write the wiki page today.

                        1 Reply Last reply
                        1
                        • Z zabaat

                          @m_andrej
                          done!
                          I actually liked it pretty well too. I did experience a small bug, I got NaN in the exploding red text for my score on my first word in one game. I was not able to replicate again though. Also the word JAY gave me ~176 points, not sure if that was intended as the other words were much lower. It was also when I only had 4 squares on the screen at the time.

                          A couple small suggestions if I may,

                          • it would be really nice to have some sort of 'clear selection' and maybe even an 'undo' button, as it's hard to deselect (at least on my iPhone 4s)
                          • a thin line or mark on the side to indicate the danger height, I kept thinking I had more room.

                          other than that very solid, and I did very much like having the whole board open to me and not being limited to just adjacent letters.

                          M Offline
                          M Offline
                          m_andrej
                          wrote on last edited by
                          #12

                          @zabaat The promised wiki page: https://wiki.qt.io/IOS_sound_from_QML_(AVAudioPlayer)

                          Z 1 Reply Last reply
                          1
                          • M m_andrej

                            @zabaat The promised wiki page: https://wiki.qt.io/IOS_sound_from_QML_(AVAudioPlayer)

                            Z Offline
                            Z Offline
                            zabaat
                            wrote on last edited by
                            #13

                            @m_andrej
                            Thank you very very much!
                            We would like to credit you in our iOS app for this. We don't mind linking to a site or just having your username or something. Let me know what you'd prefer.

                            Thanks again

                            M 1 Reply Last reply
                            0
                            • Z zabaat

                              @m_andrej
                              Thank you very very much!
                              We would like to credit you in our iOS app for this. We don't mind linking to a site or just having your username or something. Let me know what you'd prefer.

                              Thanks again

                              M Offline
                              M Offline
                              m_andrej
                              wrote on last edited by
                              #14

                              @zabaat That's kind of you, but did you notice that my code has a bug? I mentioned it in the text. It's leaking memory and I don't know how to fix this (I am not proficient in Obj-C). Somebody who has experience in Obj-C should have a look at it.

                              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