Android: problem with video



  • Hi,

    I'm trying to make a simple app for Android using QT 5.1, which has to show a video from Internet.
    I know it should be possible since in the QT5 Everywhere demo it works, and if I start the app for the desktop it works as well. But in the Android case I get these warnings and errors and no video player is displayed when the app starts:

    @/System.err(30395): java.lang.InstantiationException: can't instantiate class org.qtproject.qt5.android.multimedia.QtAndroidMediaPlayer; no empty constructor
    W/System.err(30395): at java.lang.Class.newInstanceImpl(Native Method)
    W/System.err(30395): at java.lang.Class.newInstance(Class.java:1319)
    W/System.err(30395): at org.qtproject.qt5.android.QtActivityDelegate.loadApplication(QtActivityDelegate.java:314)
    W/System.err(30395): at java.lang.reflect.Method.invokeNative(Native Method)
    W/System.err(30395): at java.lang.reflect.Method.invoke(Method.java:511)
    W/System.err(30395): at org.qtproject.qt5.android.bindings.QtActivity.loadApplication(QtActivity.java:200)
    W/System.err(30395): at org.qtproject.qt5.android.bindings.QtActivity.startApp(QtActivity.java:484)
    W/System.err(30395): at org.qtproject.qt5.android.bindings.QtActivity.onCreate(QtActivity.java:688)
    W/System.err(30395): at android.app.Activity.performCreate(Activity.java:5104)
    W/System.err(30395): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
    W/System.err(30395): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
    W/System.err(30395): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
    W/System.err(30395): at android.app.ActivityThread.access$600(ActivityThread.java:141)
    W/System.err(30395): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
    W/System.err(30395): at android.os.Handler.dispatchMessage(Handler.java:99)
    W/System.err(30395): at android.os.Looper.loop(Looper.java:137)
    W/System.err(30395): at android.app.ActivityThread.main(ActivityThread.java:5041)
    W/System.err(30395): at java.lang.reflect.Method.invokeNative(Native Method)
    W/System.err(30395): at java.lang.reflect.Method.invoke(Method.java:511)
    W/System.err(30395): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    W/System.err(30395): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
    W/System.err(30395): at dalvik.system.NativeStart.main(Native Method)@

    And below:

    @D/MediaPlayer(30395): Couldn't open file on client side, trying server side
    E/MediaPlayer(30395): Attempt to call getDuration without a valid mediaplayer
    E/MediaPlayer(30395): error (-38, 0)
    E/MediaPlayer(30395): Error (-38,0)@

    I googled for possible solutions but didn't find anything relevant so far. I checked and the "libQt5MultimediaQuick_p" library is loaded.

    My simple QML file:

    @import QtQuick 2.0
    import QtMultimedia 5.0

    Rectangle {
    width: 800
    height: 600
    color: "white"

    MediaPlayer {
        id: player
        source: "http://download.qt-project.org/learning/videos/Lars_Knoll_The_Making_of_Qt_5.mp4"
        autoPlay: true
    }
    
    VideoOutput {
        id: videoOutput
        source: player
        anchors.fill: parent
    }
    

    }@

    Did someone have success with playing a video from the internet?



  • I didnt test that yet, but maybe you forgot to add the permission to access the internet? I dont know if the Qt creator does that automatically, but you definitely need to set the permission to access the internet in the android manifest. The Qt creator can also do that in the project settings. I think Run and then Package Configurations.



  • Hi,

    Thank you for your answer.
    Yes I already checked that. Qt Creator adds this permission automatically to the manifest, so it seems to be something else.

    Maybe someone has another idea about this issue?



  • I'm having the same problem, I can't seem to get the QML MediaPlayer to do anything useful on an Android device. I am using an Android 4.0.4 tablet and build for Android 4.0.3.

    If a use a URL for my video source (in my case, source: "http://192.168.86.87/nognomes.mp4") I get:

    @D/MediaPlayer(24678): Couldn't open file on client side, trying server side
    E/MediaPlayer(24678): Attempt to call getDuration without a valid mediaplayer
    E/MediaPlayer(24678): error (-38, 0)
    E/MediaPlayer(24678): Error (-38,0)
    @

    From the same URL source I can load and show a png into a QML Image element without any problem (in my case, source: "http://192.168.86.87/Gnome_Home.png";)

    I also tried putting my media onto an SD card and reading it from there. My PNG image shows up just fine, but the MediaPlayer does nothing and I see this in the app log:

    @E/MediaPlayer(24272): error (1, -2147483648)
    E/MediaPlayer(24272): Error (1,-2147483648)
    @

    FYI, -2147483648 == 0x80000000



  • Same still with issue with qt 5.2, any update or workarround for armv7


Log in to reply
 

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