I'm trying to play a video with sound in an iOS application with Qt or Qml. My environment is :
- Qt 5.4
- OSX Yosemite 10.10.2
- iPad 2 (iOS 8.3) and Iphone6+ (iOS 8.3)
Test code (QML version):
import QtQuick 2.4
import QtMultimedia 5.0
VideoOutput {
anchors.fill: parent
fillMode: VideoOutput.PreserveAspectFit
source: player
MediaPlayer {
id: player
autoPlay: true
onStatusChanged: {if (status==MediaPlayer.EndOfMedia) play();}
source: "qrc:/videos/vid2.mp4"
}
}
Test code (C++ version):
QMainWindow w;
QVideoWidget* pVWidget = new QVideoWidget;
QMediaPlayer* pPlayer = new QMediaPlayer;
pPlayer->setMedia(QUrl("qrc:/videos/vid2.mp4"));
w.setCentralWidget(pVWidget);
w.show();
pPlayer->play();
My project file (.pro
):
TEMPLATE = app
QT += core gui network sql widgets xmlpatterns quick qml multimedia multimediawidgets
SOURCES += main.cpp
RESOURCES += qml.qrc
Source tested :
- from resource:
qrc://videos/vid2.mp4
- from local file after successfull copy on the storage :
/var/mobile/Containers/Data/Application/12BD0B54-46B3-439F-9869-E06E1AC6CD87/Library/Application Support/data/vid1.mp4
- from video online :
http://www.rmh.de/9d0386eada217cd63a752458aeca89d6/9d0386eada217cd63a752458aeca89d6.mp4
Everything works fine when executed Android or OS X whereas execution fails both on iOS devices and iOS Simulator.
I tried adding the QTPLUGING
but, as it should be, Creator found that it was duplicating. I tried using QMAKE_BUNDLE_DATA
but that didn't work either. I got a white screen on QML version and black screen on C++ version.
Thanks for your help.