Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-54506

QMediaPlayer in an Android Service does not work

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: 5.7.0
    • Fix Version/s: 5.7.1
    • Component/s: Multimedia
    • Labels:
      None
    • Environment:
      Qt 5.7.0, Android 5.1.1 and 6.0
    • Platform/s:
      Android

      Description

      Attempting to use QMediaPlayer to play an ogg vorbis (or mp3) results in no media playback and this error:

      D/Qt MediaPlayer( 3297): Attempt to invoke virtual method 'android.content.ContentResolver android.content.Context.getContentResolver()' on a null object reference

      Related to this, this error appears on initialization when adding "multimedia" dependency. From what I can gather, it occurs when the QtMultimediaUtils are added to the android.app.static_init_classes.

      W/System.err( 3297): java.lang.NoSuchMethodException: setService [class android.app.Service, class java.lang.Object]
      W/System.err( 3297): at java.lang.Class.getMethod(Class.java:664)
      W/System.err( 3297): at java.lang.Class.getMethod(Class.java:643)
      W/System.err( 3297): at org.qtproject.qt5.android.QtServiceDelegate.loadApplication(QtServiceDelegate.java:127)
      W/System.err( 3297): at java.lang.reflect.Method.invoke(Native Method)
      W/System.err( 3297): at java.lang.reflect.Method.invoke(Method.java:372)
      W/System.err( 3297): at org.qtproject.qt5.android.bindings.QtLoader.loadApplication(QtLoader.java:237)
      W/System.err( 3297): at org.qtproject.qt5.android.bindings.QtLoader.startApp(QtLoader.java:647)
      W/System.err( 3297): at org.qtproject.qt5.android.bindings.QtServiceLoader.onCreate(QtServiceLoader.java:60)
      W/System.err( 3297): at org.qtproject.qt5.android.bindings.QtService.onCreate(QtService.java:57)
      W/System.err( 3297): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2761)
      W/System.err( 3297): at android.app.ActivityThread.access$1800(ActivityThread.java:151)
      W/System.err( 3297): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1386)
      W/System.err( 3297): at android.os.Handler.dispatchMessage(Handler.java:102)
      W/System.err( 3297): at android.os.Looper.loop(Looper.java:135)
      W/System.err( 3297): at android.app.ActivityThread.main(ActivityThread.java:5254)
      W/System.err( 3297): at java.lang.reflect.Method.invoke(Native Method)
      W/System.err( 3297): at java.lang.reflect.Method.invoke(Method.java:372)
      W/System.err( 3297): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
      W/System.err( 3297): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

      I've attached a minimal example of this in action.

        Attachments

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              Assignee:
              taipan BogDan Vatra
              Reporter:
              ckaiser Christian Kaiser
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews