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. Playing Videos from C++ using QML on Android does not work either
Forum Updated to NodeBB v4.3 + New Features

Playing Videos from C++ using QML on Android does not work either

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
2 Posts 2 Posters 1.4k 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.
  • B Offline
    B Offline
    barade123
    wrote on last edited by
    #1

    Since QVideoWidget is not supported on Android I have created a QML file which contains a MediaPlayer instance and a VideoOutput. Using C++ I set the source to a path with assets:/ on Android. I show the widget with a green background. Unfortunately, the video is played but only sound is played no image.

    This is my QML script:

    import QtQuick 2.0
    import QtQuick.Controls 1.2
    import QtMultimedia 5.6
    
    Rectangle {
        width: 200
        height: 200
        color: "black"
    
        MediaPlayer {
            id: player
            objectName: "player"
            audioRole: MediaPlayer.GameRole
            source: "assets:/vampir/vampir.avi"
            //autoPlay: true
        }
    
        VideoOutput {
            id: videoOutput
            objectName: "videoOutput"
            source: player
            anchors.fill: parent
        }
    }
    

    Here is the code I created the view:

    m_view = new QQuickView();
    
    	m_videoWidget = QWidget::createWindowContainer(m_view, this);
    	m_videoWidget->setFocusPolicy(Qt::TabFocus);
    
    	// TEST to check if the widget appears at all
    	QPalette pal;
    	pal.setColor(QPalette::Background, Qt::green);
    	m_videoWidget->setPalette(pal);
    
    	m_view->setSource(QUrl("qrc:/videoplayer.qml"));
    
    	qDebug() << "QML Errors:";
    	foreach (QQmlError error, m_view->errors())
    	{
    		qDebug() << error.description();
    	}
    
    	if (m_view != nullptr)
    	{
    		m_item = m_view->rootObject();
    		qDebug() << "Children size: " << m_item->children().size();
    
    		if (m_item != nullptr)
    		{
    			m_mediaPlayer = m_item->findChild<QObject*>("player");
    		}
    	}
    

    Here is the adb output:

    08-20 17:16:06.044  1232  1267 D NuPlayerDriver: start(0xae48c660), state is 4, eos is 0
    08-20 17:16:06.044  1232  3154 I GenericSource: start
    08-20 17:16:06.048  1232  3162 I MediaPlayerService: MediaPlayerService::getOMX
    08-20 17:16:06.048  1232  3162 I OMXClient: MuxOMX ctor
    08-20 17:16:06.048  1229  1248 I OMXMaster: makeComponentInstance(OMX.google.raw.decoder) in mediacodec process
    08-20 17:16:06.049  1229  1229 E OMXNodeInstance: setConfig(4cd002d:google.raw.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
    08-20 17:16:06.049  1232  3162 I ACodec  : codec does not support config priority (err -2147483648)
    08-20 17:16:06.049  1232  3162 I MediaCodec: MediaCodec will operate in async mode
    08-20 17:16:06.051  1232  3160 D AudioTrack: Client defaulted notificationFrames to 11264 for frameCount 22528
    08-20 17:16:06.053  1231  1817 I SampleTable: There are reordered frames present.
    08-20 17:16:06.053  1232  3158 D NuPlayerDriver: notifyListener_l(0xafca8ba0), (5, 1280, 720), loop setting(0, 0)
    08-20 17:16:06.053  1232  3158 D NuPlayerDriver: notifyListener_l(0xafca8ba0), (1, 0, 0), loop setting(0, 0)
    08-20 17:16:06.053  2940  2940 D MediaPlayer: setSubtitleAnchor in MediaPlayer
    08-20 17:16:06.054  1232  1648 D NuPlayerDriver: start(0xafca8ba0), state is 4, eos is 0
    08-20 17:16:06.054  1232  3158 I GenericSource: start
    08-20 17:16:06.058  1232  3154 D NuPlayerDriver: notifyListener_l(0xae48c660), (6, 0, 0), loop setting(0, 0)
    08-20 17:16:06.058  1232  3161 I NuPlayerDecoder: [audio] saw output EOS
    08-20 17:16:06.060  1231  1817 I SampleTable: There are reordered frames present.
    08-20 17:16:06.062  1232  3169 I MediaPlayerService: MediaPlayerService::getOMX
    08-20 17:16:06.062  1232  3171 I MediaPlayerService: MediaPlayerService::getOMX
    08-20 17:16:06.062  1232  3169 I OMXClient: MuxOMX ctor
    08-20 17:16:06.062  1232  3171 I OMXClient: MuxOMX ctor
    08-20 17:16:06.062  1229  1646 I OMXMaster: makeComponentInstance(OMX.google.aac.decoder) in mediacodec process
    08-20 17:16:06.062  1229  1229 I OMXMaster: makeComponentInstance(OMX.google.h264.decoder) in mediacodec process
    08-20 17:16:06.073  1229  1646 E OMXNodeInstance: setConfig(4cd002e:google.aac.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
    08-20 17:16:06.073  1232  3171 I ACodec  : codec does not support config priority (err -2147483648)
    08-20 17:16:06.073  1232  3171 I MediaCodec: MediaCodec will operate in async mode
    08-20 17:16:06.074  1229  3172 I SoftAAC2: Reconfiguring decoder: 0->48000 Hz, 0->6 channels
    08-20 17:16:06.077  1232  3166 D AudioTrack: Client defaulted notificationFrames to 8169 for frameCount 24508
    08-20 17:16:06.077  1232  3158 D NuPlayerDriver: notifyListener_l(0xafca8ba0), (6, 0, 0), loop setting(0, 0)
    08-20 17:16:06.093  1232  3168 I MediaCodec: [OMX.google.h264.decoder] setting surface generation to 1261570
    08-20 17:16:06.096  1229  1646 W OMXNodeInstance: [4cd002f:google.h264.decoder] component does not support metadata mode; using fallback
    08-20 17:16:06.096  1232  3169 E ACodec  : [OMX.google.h264.decoder] storeMetaDataInBuffers failed w/ err -1010
    08-20 17:16:06.097  1229  1248 E OMXNodeInstance: setConfig(4cd002f:google.h264.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
    08-20 17:16:06.097  1232  3169 I ACodec  : codec does not support config priority (err -2147483648)
    08-20 17:16:06.097  1229  1229 E OMXNodeInstance: setConfig(4cd002f:google.h264.decoder, ConfigOperatingRate(0x6f800003)) ERROR: Undefined(0x80001001)
    08-20 17:16:06.097  1232  3169 I ACodec  : codec does not support config operating rate (err -2147483648)
    08-20 17:16:06.097  1232  3168 I MediaCodec: MediaCodec will operate in async mode
    08-20 17:16:06.132  1232  3168 D MediaCodec: [OMX.google.h264.decoder] setting dataspace on output surface to #104
    08-20 17:16:06.133  1232  3158 D NuPlayerDriver: notifyListener_l(0xafca8ba0), (5, 1280, 720), loop setting(0, 0)
    08-20 17:16:06.133  1232  3158 D NuPlayerDriver: notifyListener_l(0xafca8ba0), (200, 3, 0), loop setting(0, 0)
    08-20 17:16:06.134  2940  3156 W MediaPlayer: info/warning (3, 0)
    08-20 17:16:06.139  1232  3168 D SoftwareRenderer: setting dataspace on output surface to #104
    08-20 17:16:06.153  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(1)
    08-20 17:16:06.224  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(1)
    08-20 17:16:06.438  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(1)
    08-20 17:16:06.569  1232  3154 D NuPlayerDriver: notifyListener_l(0xae48c660), (2, 0, 0), loop setting(0, 0)
    08-20 17:16:06.570  1232  1267 D NuPlayerDriver: stop(0xae48c660)
    08-20 17:16:06.570  1232  1267 D NuPlayerDriver: notifyListener_l(0xae48c660), (8, 0, 0), loop setting(0, 0)
    08-20 17:16:06.571  1232  1648 D NuPlayerDriver: reset(0xae48c660) at state 8
    08-20 17:16:06.571  1232  3154 W AMessage: failed to post message as target looper for handler 0 is gone.
    08-20 17:16:06.572  1232  3154 D NuPlayerDriver: notifyResetComplete(0xae48c660)
    08-20 17:16:06.572  1232  1267 D NuPlayerDriver: reset(0xae48c660) at state 0
    08-20 17:16:06.642  1232  3199 D NuPlayerDriver: notifyListener_l(0xafca8e40), (1, 0, 0), loop setting(0, 0)
    08-20 17:16:06.642  2940  2940 D MediaPlayer: setSubtitleAnchor in MediaPlayer
    08-20 17:16:06.650  1232  1267 D NuPlayerDriver: start(0xafca8e40), state is 4, eos is 0
    08-20 17:16:06.650  1232  3199 I GenericSource: start
    08-20 17:16:06.702  1232  3204 I MediaPlayerService: MediaPlayerService::getOMX
    08-20 17:16:06.702  1232  3204 I OMXClient: MuxOMX ctor
    08-20 17:16:06.702  1229  1248 I OMXMaster: makeComponentInstance(OMX.google.raw.decoder) in mediacodec process
    08-20 17:16:06.702  1229  1646 E OMXNodeInstance: setConfig(4cd0030:google.raw.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
    08-20 17:16:06.702  1232  3204 I ACodec  : codec does not support config priority (err -2147483648)
    08-20 17:16:06.703  1232  3204 I MediaCodec: MediaCodec will operate in async mode
    08-20 17:16:06.708  1232  3202 D AudioTrack: Client defaulted notificationFrames to 11264 for frameCount 22528
    08-20 17:16:06.708  1232  3199 D NuPlayerDriver: notifyListener_l(0xafca8e40), (6, 0, 0), loop setting(0, 0)
    08-20 17:16:06.804  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(2)
    08-20 17:16:07.126  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(2)
    08-20 17:16:07.572  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(1)
    08-20 17:16:07.706  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(2)
    08-20 17:16:07.733  1232  3203 I NuPlayerDecoder: [audio] saw output EOS
    08-20 17:16:08.190  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(1)
    08-20 17:16:08.261  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(1)
    08-20 17:16:08.381  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(1)
    08-20 17:16:08.942  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(1)
    08-20 17:16:09.003  1232  3199 D NuPlayerDriver: notifyListener_l(0xafca8e40), (2, 0, 0), loop setting(0, 0)
    

    Is it even possible to do what I want to achieve? I'd like to avoid using another plugin or API like suggested here: http://stackoverflow.com/questions/38979135/qmediaplayer-on-android

    But in the end I need to play videos on Android using my Qt application and I have to react to the changing states with custom slots.

    DQUY05D 1 Reply Last reply
    0
    • B barade123

      Since QVideoWidget is not supported on Android I have created a QML file which contains a MediaPlayer instance and a VideoOutput. Using C++ I set the source to a path with assets:/ on Android. I show the widget with a green background. Unfortunately, the video is played but only sound is played no image.

      This is my QML script:

      import QtQuick 2.0
      import QtQuick.Controls 1.2
      import QtMultimedia 5.6
      
      Rectangle {
          width: 200
          height: 200
          color: "black"
      
          MediaPlayer {
              id: player
              objectName: "player"
              audioRole: MediaPlayer.GameRole
              source: "assets:/vampir/vampir.avi"
              //autoPlay: true
          }
      
          VideoOutput {
              id: videoOutput
              objectName: "videoOutput"
              source: player
              anchors.fill: parent
          }
      }
      

      Here is the code I created the view:

      m_view = new QQuickView();
      
      	m_videoWidget = QWidget::createWindowContainer(m_view, this);
      	m_videoWidget->setFocusPolicy(Qt::TabFocus);
      
      	// TEST to check if the widget appears at all
      	QPalette pal;
      	pal.setColor(QPalette::Background, Qt::green);
      	m_videoWidget->setPalette(pal);
      
      	m_view->setSource(QUrl("qrc:/videoplayer.qml"));
      
      	qDebug() << "QML Errors:";
      	foreach (QQmlError error, m_view->errors())
      	{
      		qDebug() << error.description();
      	}
      
      	if (m_view != nullptr)
      	{
      		m_item = m_view->rootObject();
      		qDebug() << "Children size: " << m_item->children().size();
      
      		if (m_item != nullptr)
      		{
      			m_mediaPlayer = m_item->findChild<QObject*>("player");
      		}
      	}
      

      Here is the adb output:

      08-20 17:16:06.044  1232  1267 D NuPlayerDriver: start(0xae48c660), state is 4, eos is 0
      08-20 17:16:06.044  1232  3154 I GenericSource: start
      08-20 17:16:06.048  1232  3162 I MediaPlayerService: MediaPlayerService::getOMX
      08-20 17:16:06.048  1232  3162 I OMXClient: MuxOMX ctor
      08-20 17:16:06.048  1229  1248 I OMXMaster: makeComponentInstance(OMX.google.raw.decoder) in mediacodec process
      08-20 17:16:06.049  1229  1229 E OMXNodeInstance: setConfig(4cd002d:google.raw.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
      08-20 17:16:06.049  1232  3162 I ACodec  : codec does not support config priority (err -2147483648)
      08-20 17:16:06.049  1232  3162 I MediaCodec: MediaCodec will operate in async mode
      08-20 17:16:06.051  1232  3160 D AudioTrack: Client defaulted notificationFrames to 11264 for frameCount 22528
      08-20 17:16:06.053  1231  1817 I SampleTable: There are reordered frames present.
      08-20 17:16:06.053  1232  3158 D NuPlayerDriver: notifyListener_l(0xafca8ba0), (5, 1280, 720), loop setting(0, 0)
      08-20 17:16:06.053  1232  3158 D NuPlayerDriver: notifyListener_l(0xafca8ba0), (1, 0, 0), loop setting(0, 0)
      08-20 17:16:06.053  2940  2940 D MediaPlayer: setSubtitleAnchor in MediaPlayer
      08-20 17:16:06.054  1232  1648 D NuPlayerDriver: start(0xafca8ba0), state is 4, eos is 0
      08-20 17:16:06.054  1232  3158 I GenericSource: start
      08-20 17:16:06.058  1232  3154 D NuPlayerDriver: notifyListener_l(0xae48c660), (6, 0, 0), loop setting(0, 0)
      08-20 17:16:06.058  1232  3161 I NuPlayerDecoder: [audio] saw output EOS
      08-20 17:16:06.060  1231  1817 I SampleTable: There are reordered frames present.
      08-20 17:16:06.062  1232  3169 I MediaPlayerService: MediaPlayerService::getOMX
      08-20 17:16:06.062  1232  3171 I MediaPlayerService: MediaPlayerService::getOMX
      08-20 17:16:06.062  1232  3169 I OMXClient: MuxOMX ctor
      08-20 17:16:06.062  1232  3171 I OMXClient: MuxOMX ctor
      08-20 17:16:06.062  1229  1646 I OMXMaster: makeComponentInstance(OMX.google.aac.decoder) in mediacodec process
      08-20 17:16:06.062  1229  1229 I OMXMaster: makeComponentInstance(OMX.google.h264.decoder) in mediacodec process
      08-20 17:16:06.073  1229  1646 E OMXNodeInstance: setConfig(4cd002e:google.aac.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
      08-20 17:16:06.073  1232  3171 I ACodec  : codec does not support config priority (err -2147483648)
      08-20 17:16:06.073  1232  3171 I MediaCodec: MediaCodec will operate in async mode
      08-20 17:16:06.074  1229  3172 I SoftAAC2: Reconfiguring decoder: 0->48000 Hz, 0->6 channels
      08-20 17:16:06.077  1232  3166 D AudioTrack: Client defaulted notificationFrames to 8169 for frameCount 24508
      08-20 17:16:06.077  1232  3158 D NuPlayerDriver: notifyListener_l(0xafca8ba0), (6, 0, 0), loop setting(0, 0)
      08-20 17:16:06.093  1232  3168 I MediaCodec: [OMX.google.h264.decoder] setting surface generation to 1261570
      08-20 17:16:06.096  1229  1646 W OMXNodeInstance: [4cd002f:google.h264.decoder] component does not support metadata mode; using fallback
      08-20 17:16:06.096  1232  3169 E ACodec  : [OMX.google.h264.decoder] storeMetaDataInBuffers failed w/ err -1010
      08-20 17:16:06.097  1229  1248 E OMXNodeInstance: setConfig(4cd002f:google.h264.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
      08-20 17:16:06.097  1232  3169 I ACodec  : codec does not support config priority (err -2147483648)
      08-20 17:16:06.097  1229  1229 E OMXNodeInstance: setConfig(4cd002f:google.h264.decoder, ConfigOperatingRate(0x6f800003)) ERROR: Undefined(0x80001001)
      08-20 17:16:06.097  1232  3169 I ACodec  : codec does not support config operating rate (err -2147483648)
      08-20 17:16:06.097  1232  3168 I MediaCodec: MediaCodec will operate in async mode
      08-20 17:16:06.132  1232  3168 D MediaCodec: [OMX.google.h264.decoder] setting dataspace on output surface to #104
      08-20 17:16:06.133  1232  3158 D NuPlayerDriver: notifyListener_l(0xafca8ba0), (5, 1280, 720), loop setting(0, 0)
      08-20 17:16:06.133  1232  3158 D NuPlayerDriver: notifyListener_l(0xafca8ba0), (200, 3, 0), loop setting(0, 0)
      08-20 17:16:06.134  2940  3156 W MediaPlayer: info/warning (3, 0)
      08-20 17:16:06.139  1232  3168 D SoftwareRenderer: setting dataspace on output surface to #104
      08-20 17:16:06.153  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(1)
      08-20 17:16:06.224  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(1)
      08-20 17:16:06.438  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(1)
      08-20 17:16:06.569  1232  3154 D NuPlayerDriver: notifyListener_l(0xae48c660), (2, 0, 0), loop setting(0, 0)
      08-20 17:16:06.570  1232  1267 D NuPlayerDriver: stop(0xae48c660)
      08-20 17:16:06.570  1232  1267 D NuPlayerDriver: notifyListener_l(0xae48c660), (8, 0, 0), loop setting(0, 0)
      08-20 17:16:06.571  1232  1648 D NuPlayerDriver: reset(0xae48c660) at state 8
      08-20 17:16:06.571  1232  3154 W AMessage: failed to post message as target looper for handler 0 is gone.
      08-20 17:16:06.572  1232  3154 D NuPlayerDriver: notifyResetComplete(0xae48c660)
      08-20 17:16:06.572  1232  1267 D NuPlayerDriver: reset(0xae48c660) at state 0
      08-20 17:16:06.642  1232  3199 D NuPlayerDriver: notifyListener_l(0xafca8e40), (1, 0, 0), loop setting(0, 0)
      08-20 17:16:06.642  2940  2940 D MediaPlayer: setSubtitleAnchor in MediaPlayer
      08-20 17:16:06.650  1232  1267 D NuPlayerDriver: start(0xafca8e40), state is 4, eos is 0
      08-20 17:16:06.650  1232  3199 I GenericSource: start
      08-20 17:16:06.702  1232  3204 I MediaPlayerService: MediaPlayerService::getOMX
      08-20 17:16:06.702  1232  3204 I OMXClient: MuxOMX ctor
      08-20 17:16:06.702  1229  1248 I OMXMaster: makeComponentInstance(OMX.google.raw.decoder) in mediacodec process
      08-20 17:16:06.702  1229  1646 E OMXNodeInstance: setConfig(4cd0030:google.raw.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
      08-20 17:16:06.702  1232  3204 I ACodec  : codec does not support config priority (err -2147483648)
      08-20 17:16:06.703  1232  3204 I MediaCodec: MediaCodec will operate in async mode
      08-20 17:16:06.708  1232  3202 D AudioTrack: Client defaulted notificationFrames to 11264 for frameCount 22528
      08-20 17:16:06.708  1232  3199 D NuPlayerDriver: notifyListener_l(0xafca8e40), (6, 0, 0), loop setting(0, 0)
      08-20 17:16:06.804  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(2)
      08-20 17:16:07.126  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(2)
      08-20 17:16:07.572  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(1)
      08-20 17:16:07.706  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(2)
      08-20 17:16:07.733  1232  3203 I NuPlayerDecoder: [audio] saw output EOS
      08-20 17:16:08.190  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(1)
      08-20 17:16:08.261  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(1)
      08-20 17:16:08.381  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(1)
      08-20 17:16:08.942  1224  1262 D AudioFlinger: mixer(0xa8583e00) throttle end: throttle time(1)
      08-20 17:16:09.003  1232  3199 D NuPlayerDriver: notifyListener_l(0xafca8e40), (2, 0, 0), loop setting(0, 0)
      

      Is it even possible to do what I want to achieve? I'd like to avoid using another plugin or API like suggested here: http://stackoverflow.com/questions/38979135/qmediaplayer-on-android

      But in the end I need to play videos on Android using my Qt application and I have to react to the changing states with custom slots.

      DQUY05D Offline
      DQUY05D Offline
      DQUY05
      wrote on last edited by
      #2

      @barade123

      Hi Mr.

      I am having a similar project of yours, but do not understand the objectName property my VideoOutput does, is it because I use Qt5.15?

      objectName: "VideoOutput" 
      

      Thanks!

      1 Reply Last reply
      0

      • Login

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