play audio from QML in iOS
-
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 insertedQDir().entryList();
into code, which confirms that italy.mp3 is really present in current directory.
I also tried to import pluginsqtaudio_coreaudio qtmedia_audioengine qavfcamera qavfmediaplayer
in my *.pro file (although this should not be necessary in Qt 5.4), but no luck.
Any ideas? -
I am having this same problem too, did you find a resolution?
-
-
This post is deleted! -
@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 pageI'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!
-
Seems there was a problem on the backend side of the wiki, but the pages are back today
-
@zabaat No, I didn't. It just doesn't work. I ended up writing platform-specific audio code in Objective-C.
-
@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!
-
@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 :-) -
@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.
-
@zabaat Thanks a lot! I will write the wiki page today.
-
@zabaat The promised wiki page: https://wiki.qt.io/IOS_sound_from_QML_(AVAudioPlayer)
-
@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
-
@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.