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. Mp3 not being played on android

Mp3 not being played on android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
14 Posts 2 Posters 1.8k Views
  • 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.
  • V Offline
    V Offline
    Vega4
    wrote on last edited by Vega4
    #4

    Turns out when file is declared in such a way within the resource file (note the voices directory):

     <qresource prefix="/new/prefix2">
            <file>voices/welcome.mp3</file>
        </qresource>
    

    the sound won't be played when referencing the file through

    QUrl("qrc:/new/prefix2/welcome.mp3")
    

    However

    when the mp3 file is not located within a directory and declared as

     <qresource prefix="/new/prefix2">
            <file>welcome.mp3</file>
        </qresource>
    

    the sound would be played.

    Is that a bug? Looks like one.

    Looks like the mp3 file doesn't make it into the binary resource file if located within a directory? is that the case? or for any other reason is not retrieved? should we file a bug-report?

    Note that in our project we've got images in nested directories and they are accessed fine. It's the case with QMediaPlayer being unable for some reason to access these.

    KroMignonK 1 Reply Last reply
    0
    • V Vega4

      Turns out when file is declared in such a way within the resource file (note the voices directory):

       <qresource prefix="/new/prefix2">
              <file>voices/welcome.mp3</file>
          </qresource>
      

      the sound won't be played when referencing the file through

      QUrl("qrc:/new/prefix2/welcome.mp3")
      

      However

      when the mp3 file is not located within a directory and declared as

       <qresource prefix="/new/prefix2">
              <file>welcome.mp3</file>
          </qresource>
      

      the sound would be played.

      Is that a bug? Looks like one.

      Looks like the mp3 file doesn't make it into the binary resource file if located within a directory? is that the case? or for any other reason is not retrieved? should we file a bug-report?

      Note that in our project we've got images in nested directories and they are accessed fine. It's the case with QMediaPlayer being unable for some reason to access these.

      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by KroMignon
      #5

      @Vega4 said in Mp3 not being played on android:

      Turns out when file is declared in such a way within the resource file (note the voices directory):

      <qresource prefix="/new/prefix2">
           <file>voices/welcome.mp3</file>
       </qresource>
      

      the sound won't be played when referencing the file through

      When using sub-directories, you have to set alias or give the full path:

      Url("qrc:/new/prefix2/voices/welcome.mp3")
      

      or

          <qresource prefix="/new/prefix2">
               <file alias="welcome.mp3">voices/welcome.mp3</file>
           </qresource>
      

      and

      Url("qrc:/new/prefix2/welcome.mp3")
      

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      1 Reply Last reply
      2
      • V Offline
        V Offline
        Vega4
        wrote on last edited by
        #6

        @KroMignon thank you so much! With full-path it indeed does work! bug... report.. what? had something like it even crossed our minds? Shame on us! Thank you for such an amazing development platform! Wizards keep on riding on!

        KroMignonK 1 Reply Last reply
        1
        • V Vega4

          @KroMignon thank you so much! With full-path it indeed does work! bug... report.. what? had something like it even crossed our minds? Shame on us! Thank you for such an amazing development platform! Wizards keep on riding on!

          KroMignonK Offline
          KroMignonK Offline
          KroMignon
          wrote on last edited by
          #7

          @Vega4 said in Mp3 not being played on android:

          Thank you for such an amazing development platform!

          Your welcome, but I am only a Qt user, like you.

          It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

          V 1 Reply Last reply
          0
          • KroMignonK KroMignon

            @Vega4 said in Mp3 not being played on android:

            Thank you for such an amazing development platform!

            Your welcome, but I am only a Qt user, like you.

            V Offline
            V Offline
            Vega4
            wrote on last edited by
            #8

            @KroMignon well then, I hope I can help you one day as well.

            1 Reply Last reply
            0
            • V Offline
              V Offline
              Vega4
              wrote on last edited by Vega4
              #9

              Just one more thing to note for all the other fellas. When if you choose to use an alias, the full-path wouldn't work anymore. This seems to hold true for any resource.

              1 Reply Last reply
              0
              • V Offline
                V Offline
                Vega4
                wrote on last edited by Vega4
                #10

                @KroMignon and other friends. Have you encountered such an issue?

                D mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
                I HwViewRootImpl: removeInvalidNode all the node in jank list is out of time
                I MediaPlayer: [HSM] stayAwake false uid: 10275, pid: 14167
                D MediaPlayerNative: Action:stop, CurrentState:MEDIA_PLAYER_STOPPED
                D MediaPlayerNative: Message: Unknown MediaEventType(8), ext1=0, ext2=0x0
                D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                V PlayerBase: baseStop() piid=13167
                I MediaPlayer: [HSM] stayAwake false uid: 10275, pid: 14167
                D MediaPlayerNative: Action:reset_l, CurrentState:MEDIA_PLAYER_IDLE
                V MediaPlayer: resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
                V MediaPlayer: cleanDrmObj: mDrmObj=null mDrmSessionId=null
                V PlayerBase: baseRelease() piid=13167 state=4
                I MediaPlayer: [HSM] stayAwake false uid: 10275, pid: 14167
                V MediaPlayer: resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
                V MediaPlayer: cleanDrmObj: mDrmObj=null mDrmSessionId=null
                I MediaPlayerNative: Pid:14167 MediaPlayer destructor MediaPlayer(0x70635cca40)
                D MediaPlayerNative: MediaPlayer::setVolume(1.000000, 1.000000)
                D MediaPlayerNative: Message: MEDIA_PREPARED(1), ext1=0, ext2=0x0
                D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                

                happens all of the sudden on Android (pretty soon). From it, seemingly the underlying (android-native)media player gets stopped and destroyed.

                The QMediaPlayer object is allocated on heap (of course) access to it is synchronized through a mutex and audio-playback attempts attempted only when in an idle-state. Ideas?

                From what I can tell this causes the upper QMediaPlayer object ending up in an invalid state with playing status. Further references to it cause corruption.

                that's what happened a moment earlier:

                D MediaPlayerNative: Message: Unknown MediaEventType(8), ext1=0, ext2=0x0
                D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                I MediaPlayer: [HSM] stayAwake false uid: 10275, pid: 14167
                D MediaPlayerNative: Action:reset_l, CurrentState:MEDIA_PLAYER_IDLE
                V MediaPlayer: resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
                V MediaPlayer: cleanDrmObj: mDrmObj=null mDrmSessionId=null
                V PlayerBase: baseRelease() piid=13159 state=4
                I MediaPlayer: [HSM] stayAwake false uid: 10275, pid: 14167
                V MediaPlayer: resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
                V MediaPlayer: cleanDrmObj: mDrmObj=null mDrmSessionId=null
                I MediaPlayerNative: Pid:14167 MediaPlayer destructor MediaPlayer(0x70635cca40)
                D MediaPlayerNative: MediaPlayer::setVolume(1.000000, 1.000000)
                D MediaPlayerNative: Message: MEDIA_PREPARED(1), ext1=0, ext2=0x0
                D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                V PlayerBase: baseStart() piid=13167
                I MediaPlayer: [HSM] stayAwake true uid: 10275, pid: 14167
                D MediaPlayerNative: Action:start, CurrentState:MEDIA_PLAYER_STARTED
                D MediaPlayerNative: Message: Unknown MediaEventType(6), ext1=0, ext2=0x0
                D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                D MediaPlayerNative: Message: MEDIA_PLAYBACK_COMPLETE(2), ext1=0, ext2=0x0
                D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                V PlayerBase: baseStop() piid=13167
                D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                I MediaPlayer: [HSM] stayAwake false uid: 10275, pid: 14167
                

                During normal operation it goes like this:

                D MediaPlayerNative: Action:reset_l, CurrentState:MEDIA_PLAYER_IDLE
                V MediaPlayer: resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
                V MediaPlayer: cleanDrmObj: mDrmObj=null mDrmSessionId=null
                V PlayerBase: baseRelease() piid=13583 state=4
                I MediaPlayer: [HSM] stayAwake false uid: 10275, pid: 20388
                V MediaPlayer: resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
                V MediaPlayer: cleanDrmObj: mDrmObj=null mDrmSessionId=null
                I MediaPlayerNative: Pid:20388 MediaPlayer destructor MediaPlayer(0x707d20ee00)
                D MediaPlayerNative: MediaPlayer::setVolume(1.000000, 1.000000)
                D MediaPlayerNative: Message: MEDIA_PREPARED(1), ext1=0, ext2=0x0
                D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                V PlayerBase: baseStart() piid=13591
                I MediaPlayer: [HSM] stayAwake true uid: 10275, pid: 20388
                D MediaPlayerNative: Action:start, CurrentState:MEDIA_PLAYER_STARTED
                D MediaPlayerNative: Message: Unknown MediaEventType(6), ext1=0, ext2=0x0
                D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                D MediaPlayerNative: Message: MEDIA_PLAYBACK_COMPLETE(2), ext1=0, ext2=0x0
                D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                V PlayerBase: baseStop() piid=13591
                I MediaPlayer: [HSM] stayAwake false uid: 10275, pid: 20388
                
                KroMignonK 1 Reply Last reply
                0
                • V Vega4

                  @KroMignon and other friends. Have you encountered such an issue?

                  D mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
                  I HwViewRootImpl: removeInvalidNode all the node in jank list is out of time
                  I MediaPlayer: [HSM] stayAwake false uid: 10275, pid: 14167
                  D MediaPlayerNative: Action:stop, CurrentState:MEDIA_PLAYER_STOPPED
                  D MediaPlayerNative: Message: Unknown MediaEventType(8), ext1=0, ext2=0x0
                  D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                  V PlayerBase: baseStop() piid=13167
                  I MediaPlayer: [HSM] stayAwake false uid: 10275, pid: 14167
                  D MediaPlayerNative: Action:reset_l, CurrentState:MEDIA_PLAYER_IDLE
                  V MediaPlayer: resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
                  V MediaPlayer: cleanDrmObj: mDrmObj=null mDrmSessionId=null
                  V PlayerBase: baseRelease() piid=13167 state=4
                  I MediaPlayer: [HSM] stayAwake false uid: 10275, pid: 14167
                  V MediaPlayer: resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
                  V MediaPlayer: cleanDrmObj: mDrmObj=null mDrmSessionId=null
                  I MediaPlayerNative: Pid:14167 MediaPlayer destructor MediaPlayer(0x70635cca40)
                  D MediaPlayerNative: MediaPlayer::setVolume(1.000000, 1.000000)
                  D MediaPlayerNative: Message: MEDIA_PREPARED(1), ext1=0, ext2=0x0
                  D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                  

                  happens all of the sudden on Android (pretty soon). From it, seemingly the underlying (android-native)media player gets stopped and destroyed.

                  The QMediaPlayer object is allocated on heap (of course) access to it is synchronized through a mutex and audio-playback attempts attempted only when in an idle-state. Ideas?

                  From what I can tell this causes the upper QMediaPlayer object ending up in an invalid state with playing status. Further references to it cause corruption.

                  that's what happened a moment earlier:

                  D MediaPlayerNative: Message: Unknown MediaEventType(8), ext1=0, ext2=0x0
                  D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                  I MediaPlayer: [HSM] stayAwake false uid: 10275, pid: 14167
                  D MediaPlayerNative: Action:reset_l, CurrentState:MEDIA_PLAYER_IDLE
                  V MediaPlayer: resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
                  V MediaPlayer: cleanDrmObj: mDrmObj=null mDrmSessionId=null
                  V PlayerBase: baseRelease() piid=13159 state=4
                  I MediaPlayer: [HSM] stayAwake false uid: 10275, pid: 14167
                  V MediaPlayer: resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
                  V MediaPlayer: cleanDrmObj: mDrmObj=null mDrmSessionId=null
                  I MediaPlayerNative: Pid:14167 MediaPlayer destructor MediaPlayer(0x70635cca40)
                  D MediaPlayerNative: MediaPlayer::setVolume(1.000000, 1.000000)
                  D MediaPlayerNative: Message: MEDIA_PREPARED(1), ext1=0, ext2=0x0
                  D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                  V PlayerBase: baseStart() piid=13167
                  I MediaPlayer: [HSM] stayAwake true uid: 10275, pid: 14167
                  D MediaPlayerNative: Action:start, CurrentState:MEDIA_PLAYER_STARTED
                  D MediaPlayerNative: Message: Unknown MediaEventType(6), ext1=0, ext2=0x0
                  D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                  D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                  D MediaPlayerNative: Message: MEDIA_PLAYBACK_COMPLETE(2), ext1=0, ext2=0x0
                  D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                  V PlayerBase: baseStop() piid=13167
                  D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                  I MediaPlayer: [HSM] stayAwake false uid: 10275, pid: 14167
                  

                  During normal operation it goes like this:

                  D MediaPlayerNative: Action:reset_l, CurrentState:MEDIA_PLAYER_IDLE
                  V MediaPlayer: resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
                  V MediaPlayer: cleanDrmObj: mDrmObj=null mDrmSessionId=null
                  V PlayerBase: baseRelease() piid=13583 state=4
                  I MediaPlayer: [HSM] stayAwake false uid: 10275, pid: 20388
                  V MediaPlayer: resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
                  V MediaPlayer: cleanDrmObj: mDrmObj=null mDrmSessionId=null
                  I MediaPlayerNative: Pid:20388 MediaPlayer destructor MediaPlayer(0x707d20ee00)
                  D MediaPlayerNative: MediaPlayer::setVolume(1.000000, 1.000000)
                  D MediaPlayerNative: Message: MEDIA_PREPARED(1), ext1=0, ext2=0x0
                  D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                  V PlayerBase: baseStart() piid=13591
                  I MediaPlayer: [HSM] stayAwake true uid: 10275, pid: 20388
                  D MediaPlayerNative: Action:start, CurrentState:MEDIA_PLAYER_STARTED
                  D MediaPlayerNative: Message: Unknown MediaEventType(6), ext1=0, ext2=0x0
                  D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                  D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                  D MediaPlayerNative: Message: MEDIA_PLAYBACK_COMPLETE(2), ext1=0, ext2=0x0
                  D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                  D MediaPlayerNative: [notify] : [1170] callback app listenerNotNull=1, send=1
                  V PlayerBase: baseStop() piid=13591
                  I MediaPlayer: [HSM] stayAwake false uid: 10275, pid: 20388
                  
                  KroMignonK Offline
                  KroMignonK Offline
                  KroMignon
                  wrote on last edited by
                  #11

                  @Vega4 said in Mp3 not being played on android:

                  happens all of the sudden on Android (pretty soon). From it, seemingly the underlying (android-native)media player gets stopped and destroyed.
                  The QMediaPlayer object is allocated on heap (of course) access to it is synchronized through a mutex and audio-playback attempts attempted only when in an idle-state. Ideas?

                  Sorry, I don't have so many experience with QMediaPlayer and Android.

                  It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                  V 1 Reply Last reply
                  0
                  • KroMignonK KroMignon

                    @Vega4 said in Mp3 not being played on android:

                    happens all of the sudden on Android (pretty soon). From it, seemingly the underlying (android-native)media player gets stopped and destroyed.
                    The QMediaPlayer object is allocated on heap (of course) access to it is synchronized through a mutex and audio-playback attempts attempted only when in an idle-state. Ideas?

                    Sorry, I don't have so many experience with QMediaPlayer and Android.

                    V Offline
                    V Offline
                    Vega4
                    wrote on last edited by
                    #12

                    @KroMignon

                    No worries, seems like the legends were true. People place objects on stack since the support of state-management of underlying native objects is well... all it takes for it to become dead is for the window to get into the background.

                    1 Reply Last reply
                    0
                    • V Offline
                      V Offline
                      Vega4
                      wrote on last edited by Vega4
                      #13

                      after more investigation seems like the QMediaPlayer at least on Android is utterly broken.

                      It's one thing to get it play an mp3 2-5 times it's entirely different thing for it to remain stable.

                      We wanted to wrap around its problems by making a new instance every time it's used and use it's callbacks to manage state around these mechanics. No luck. Once one explicitly deletes an instance of QMediaPlayer no other instance would work.

                      For instance the code below

                      if(mPlayer!=nullptr)
                          {//will be null only first time
                              delete mPlayer;//we do this before rather than after as it might still be alive when receiving notificaiton about it stopping playing
                              mPlayer=nullptr;
                          }
                      
                          mPlayer = new QMediaPlayer();
                         connect(mPlayer, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(playerStateChanged(QMediaPlayer::State)));
                      

                      Everything else held constant, were the player not delated and instantiated anew the sound would be played. BUT we delete it, create anew. no sound. We can't live with one global instance as it wouldn't survive.

                      And were we to make an instance on stack as the legends advise we can't as we need to be using the on-change callback and the object would be destroyed thus slots not fire by the time the audio finishes playing.

                      Abra kadabra.

                      What seems to indicate that the QMediaPlayer is about to die is the following in log:

                      MediaPlayerNative: Message: Unknown MediaEventType(8)
                      

                      QT relies on Android's player and Android devs call the player a 'State-Hell' so.... seems like QT devs need give it some love.
                      link text

                      1 Reply Last reply
                      0
                      • V Offline
                        V Offline
                        Vega4
                        wrote on last edited by
                        #14

                        @Vega4 said in Mp3 not being played on android:

                        resetDrmState

                        Bug Report: here

                        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