Audio Player:The QMediaPlayer object does not have a valid service



  • Hi,

    I am trying to develop an app (qml only) using the Audio object (QtMultimedia 5.5). Now I get this error:

    Audio Player:The QMediaPlayer object does not have a valid service

    what does it mean and how can I solve it?



  • @wdehoog said in Audio Player:The QMediaPlayer object does not have a valid service:

    Player:The QMediaPlayer object does not have a valid service

    Check if the this help, it seems it might be related to gstreamer.
    Installing gstreamer-devel might help, as it seems in that topic.



  • It looks like apparmor is unhappy. Still no idea how to fix it.
    I added networking, audio and video but it is still not allowed.

    from the cache/upstart/ log:

    virtual QMediaService* AalServicePlugin::create(const QString&) "org.qt-project.qt.mediaplayer"
    [TT 2017-11-12 11:31:32.904333] [service.cpp:29@instance]
    Failed to start a new media-hub player session: org.freedesktop.DBus.Error.AccessDenied: An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.77286" (uid=32011 pid=3801 comm="/usr/lib/arm-linux-gnueabihf/qt5/bin/qmlscene shou") interface="core.ubuntu.media.Service" member="CreateSession" error name="(unset)" requested_reply="0" destination="core.ubuntu.media.Service" (uid=32011 pid=3132 comm="media-hub-server ")
    Failed to create a new media player backend. Video playback will not function.

    Could not finish contructing new AalMediaPlayerService instance since m_hubPlayerSession is NULL
    virtual void QDeclarativeAudio::componentComplete()
    qml: shoutcast-ubports
    QNetworkManagerInterface::QNetworkManagerInterface(QObject*) propsReply "An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.29030" (uid=32011 pid=3801 comm="/usr/lib/arm-linux-gnueabihf/qt5/bin/qmlscene shou") interface="org.freedesktop.DBus.Properties" member="GetAll" error name="(unset)" requested_reply="0" destination="org.freedesktop.NetworkManager" (uid=0 pid=2023 comm="NetworkManager ")"
    QNetworkManagerInterface::QNetworkManagerInterface(QObject*) nmReply "An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.29030" (uid=32011 pid=3801 comm="/usr/lib/arm-linux-gnueabihf/qt5/bin/qmlscene shou") interface="org.freedesktop.NetworkManager" member="GetDevices" error name="(unset)" requested_reply="0" destination="org.freedesktop.NetworkManager" (uid=0 pid=2023 comm="NetworkManager ")"
    "Object path cannot be empty"
    library "/vendor/lib/egl/libGLESv2S3D_adreno.so" not found



  • After disabling apparmor (modified linux commandline in boot.img, apparmor=0 security="") these errprs are gone.

    Now the errors are:

    setMedia() media: QUrl( "http://144.217.49.251:80/stream1" )
    virtual QMediaPlayer::MediaStatus AalMediaPlayerControl::mediaStatus() const

    Setting media to: QUrl( "http://144.217.49.251:80/stream1" )
    Failed to set media QUrl( "http://144.217.49.251:80/stream1" ) : org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

    Can't the media thing behind the qml Audio item handle http url's? wget can handle this adres on the phone.



  • When completely disabling apparmor even the music app cannot play anmore. So back to apparmor.

    As explained here https://wiki.ubuntu.com/Touch/DeprecatedPorting one can disable it for click apps (application-click.conf). When I do that Audio works.

    Now I'd like to know how to detect which policy denies my app to play audio so I can add this to the apparmor file.



  • I don't know anything about apparmor.

    Did it help you to check the apparmor file from other programms? How they handle this?

    https://open.uappexplorer.com/app/utmedia.nfsprodriver

    https://github.com/nfsprodriver/UTmedia/blob/master/UTmedia.apparmor



  • @Einstein212 thanks. UTmedia does work on my phone but when I copy it's apparmor stuff it does not help. Maybe because UTmedia is a webapp and mine is qml.

    Even if I add all policies in the IDE still using Audio is DENIED.

    Could it be the way I install it?
    I use 'pkcon --allow-untrusted install-local'.



  • It appears that when installing my click app there is a apparmor profile being made in /var/lib/apparmor/profiles/. It also appears none of the policies I added are being addressed in the generated profile.

    I edited the generated profile and added

    #include <abstractions/audio>
    #include <abstractions/dbus-strict>
    #include <abstractions/dbus-session-strict>

    reloaded the profile and now the Audio tag works.

    So how is this ever supposed to work?



  • sorry that should have been:

    #include <abstractions/audio>
    #include <abstractions/dbus>
    #include <abstractions/dbus-session>

    the -strict ones did not help



  • @wdehoog said in Audio Player:The QMediaPlayer object does not have a valid service:

    @Einstein212 thanks. UTmedia does work on my phone but when I copy it's apparmor stuff it does not help. Maybe because UTmedia is a webapp and mine is qml.

    Maybe you can find another open source, UT, audio app that is qml to check



  • Installing my click using 'pkcon...' generates a different profile file then when done manually (aa-clicktool & aa-easyprof see https://wiki.ubuntu.com/SecurityTeam/Specifications/ApplicationConfinement/Manifest). The manual way adds extra rules that allow the app to use the media-hub.

    I noticed that uninstalling the app did not remove the profile. Manually removing the profile (from /var/lib/apparmor/profiles and from /var/cache/apparmor/) and then reinstalling the click resulted in a profile that could actually work.

    After loading it (apparmor_parser -r) my app works!

    So I think that after adding the policies in the IDE and installing the new click the previous profile (without the policies) was still being used. Question is why? Maybe because the profiles are cached and I did not increase the version number of my app.



  • First and maybe only release of the app is now available here: shoutcast-ubports.wdehoog_0.1_all.click

    It is a shoutcast browser and player. Sources and screenshots are on github

    Please give it a try. I only tested it on my moto g 2nd (thank you walidham) but like to know if it works on other devices before submitting it to the OpenStore.



  • @wdehoog I download and install the click package. But i don't get an icon on my home screen to start your program

    Do you think it is hard work to get a program made for soundcloud?



  • @Einstein212 did the icon not appear after refreshing home (pull down to refresh)?

    Does soundcloud have an API to browse/search and retrieve lists?



  • @wdehoog now i did a refresh and it's there. Nice work. Rock Antenne is running :)

    https://developers.soundcloud.com/ here are some infos for developer, but i don't have api experience to say this informations makes it possible to build a programm around this.



  • @Einstein212 I did not know about soundcloud and now see that it supports a lot of features. It will be no small effort. As it is of no use to me I am not going to work on it. If you are a developer yourself and need help I might be of use.

    There is a project on github that could be of interest to you https://github.com/lukedirtwalker/musikloud2 looks like a soundcloud client for sailfish maybe parts can be used for a ubports app.



  • @wdehoog i'd love to develop stuff for ubports, but my skills not good enough. Also i have not so much free time at the moment to lern something :(

    Thanks for the link, i will take a look on the code.


Log in to reply
 

Looks like your connection to UBports Forum was lost, please wait while we try to reconnect.