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. no Audio in QML on iOS
Qt 6.11 is out! See what's new in the release blog

no Audio in QML on iOS

Scheduled Pinned Locked Moved Solved Mobile and Embedded
2 Posts 1 Posters 784 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.
  • M Offline
    M Offline
    Marc_Van_Daele
    wrote on last edited by Marc_Van_Daele
    #1

    I'm using Qt 5.12.4 (and Xcode 11) and have the following QML

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtMultimedia 5.8
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        Audio {
            id: audio
            loops: Audio.Infinite
            onStatusChanged:        console.log("status = " + status)
            onError:                console.log("error = " + error + " " + errorString)
            onPlaybackStateChanged: console.log("playbackstate = " + playbackState)
            source: "qrc:/sounds/audio.mp3"
            volume: 1.0
        }
        Component.onCompleted: audio.play()
    }
    

    I have a sounds subdirectory at the same level as my .pro file and I have added sounds/audio.mp3 to the qrc. This works fine on eg Linux and Mac. When running this application on an actual iPhone, I see the following loglines

    QML debugging is enabled. Only use this in a safe environment.
    qml: status = 2
    stale focus object QObject(0x0) , doing manual update
    qml: playbackstate = 1
    qml: status = 6
    qml: status = 7
    qml: status = 3
    qml: playbackstate = 0
    qml: status = 6
    qml: playbackstate = 1
    qml: status = 7
    ...
    

    so it seems that the file is found and played back correctly. However, I can hear nothing at all. Other apps on my Phone do play sounds.

    I've also tried using a construct like in my *.pro file as suggested here

    SOUND_FILES = ./sounds/audio.mp3
    ios {
      sound.files = $$SOUND_FILES
      sound.path = sounds
      QMAKE_BUNDLE_DATA = sound
    }
    

    but by doing so, I always got qml: error = 1 Attempting to play invalid Qt resource (I tried /sounds/audio.mp3, sounds/audio.mp3, audio.mp3)

    Any ideas? A working example maybe?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Marc_Van_Daele
      wrote on last edited by
      #2

      Solved: see https://forum.qt.io/topic/107325/ios-no-audio-when-mute-switch-is-on-other-apps

      1 Reply Last reply
      1

      • Login

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