Solved QMediaPlayer setMedia with http url on Mac
-
i got an error when i invoked
player->setMedia(QUrl(mp3Url));
error:
2016-01-03 20:51:51.026 myPlayer[2894:385220] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
-
Hi and welcome
The error says whats wrong.
for a temp solution, please see
http://stackoverflow.com/questions/31254725/transport-security-has-blocked-a-cleartext-http -
@mrjj how to set the
NSAllowsArbitraryLoads
key to YES ?? -
@caelum
Can u click the arrow up/down to change it ?
Its it locked or something?
Also the other post
http://stackoverflow.com/questions/31216758/how-can-i-add-nsapptransportsecurity-to-my-info-plist-file/31629980#31629980
talks about adding it. -
@mrjj i built the project in qtcreator , not in xcode
-
@caelum
ok, so you need to generate the file yourself it seems.
http://stackoverflow.com/questions/19293387/qt-generate-info-plist-fileBut if u are just trying to play local mp3 file then you can just do
player->setMedia(QUrl::fromLocalFile("/Users/me/Music/coolsong.mp3")); -
@mrjj thank you , can u show me the detail how to generate the info.plist file and set
NSAllowsArbitraryLoads
key to YES? i am a newb of qt :)... -
@caelum
Hi, im afraid im even bigger noob with mac OS
it seems that you must add
QMAKE_INFO_PLIST += $${TARGET}/data/default.plist
QMAKE_POST_LINK += sed -i -e "s/@VERSION@/$$VERSION/g" "./$${TARGET}.app/Contents/Info.plist";
to your pro file.
then it will create one in the Contents folderReading this, it already sounds like Creator will make a default one.
http://wiki.qt.io/OS_X_application_without_menu_barSo in any case, you should open this file for editing in editor.
then add<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key><true/> </dict>
just before the last
</plist>Also just to be clear. It makes app less secure as I understand it.
-
@mrjj thank you very much, it works for me :)
-
@caelum
Oh that is good news :)