Hi everybody!
I'm newbie in Qt and I'm trying to play a movie in Phonon on a embedded system.
This is my code:
//mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <Phonon>
Phonon::VideoPlayer *vP;
Phonon::SeekSlider *sL;
{
foreach
(QString phonon_video_fmt, Phonon
::BackendCapabilities::availableMimeTypes()) phonon_supportedFormats << phonon_video_fmt;
qDebug() << "phonon_supportedFormats:"<<phonon_supportedFormats;
ui->setupUi(this);
vP = new Phonon::VideoPlayer(Phonon::VideoCategory, ui->Video);
vP->setParent(ui->Video);
vP->load(Phonon::MediaSource("test256x144.avi"));
vP->setGeometry(0,0,256,144);
vP->setVolume(0.25);
sL = new Phonon::SeekSlider(this);
sL->setGeometry(30,237,220,20);
sL->setMediaObject(vP->mediaObject());
}
MainWindow::~MainWindow()
{
delete ui;
delete vP;
delete sL;
}
void MainWindow
::changeEvent(QEvent *e
) {
switch (e->type())
{
ui->retranslateUi(this);
break;
default:
break;
}
}
void MainWindow::on_verticalSlider_sliderMoved(int position)
{
vP->setVolume(position / 100.0);
}
void MainWindow::on_Btt_Up_clicked()
{
ui->Video->move(ui->Video->x(),8);
}
void MainWindow::on_Btt_Dw_clicked()
{
ui->Video->move(ui->Video->x(),48);
}
void MainWindow::on_Btt_play_clicked()
{
if (ui->Btt_play->text() == "Play")
{
vP->play();
ui->Btt_play->setText("Pause");
}
else
{
vP->pause();
ui->Btt_play->setText("Play");
}
}
//mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <Phonon>
Phonon::VideoPlayer *vP;
Phonon::SeekSlider *sL;
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
QStringList phonon_supportedFormats;
foreach (QString phonon_video_fmt, Phonon::BackendCapabilities::availableMimeTypes())
phonon_supportedFormats << phonon_video_fmt;
qDebug() << "phonon_supportedFormats:"<<phonon_supportedFormats;
ui->setupUi(this);
vP = new Phonon::VideoPlayer(Phonon::VideoCategory, ui->Video);
vP->setParent(ui->Video);
vP->load(Phonon::MediaSource("test256x144.avi"));
vP->setGeometry(0,0,256,144);
vP->setVolume(0.25);
sL = new Phonon::SeekSlider(this);
sL->setGeometry(30,237,220,20);
sL->setMediaObject(vP->mediaObject());
}
MainWindow::~MainWindow()
{
delete ui;
delete vP;
delete sL;
}
void MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
switch (e->type())
{
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void MainWindow::on_verticalSlider_sliderMoved(int position)
{
vP->setVolume(position / 100.0);
}
void MainWindow::on_Btt_Up_clicked()
{
ui->Video->move(ui->Video->x(),8);
}
void MainWindow::on_Btt_Dw_clicked()
{
ui->Video->move(ui->Video->x(),48);
}
void MainWindow::on_Btt_play_clicked()
{
if (ui->Btt_play->text() == "Play")
{
vP->play();
ui->Btt_play->setText("Pause");
}
else
{
vP->pause();
ui->Btt_play->setText("Play");
}
}
To copy to clipboard, switch view to plain text mode
And this is my main class:
//main.cpp
#include <QtGui/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
a.setApplicationName("PhononTest");
MainWindow w;
w.setWindowTitle("Simple Player");
w.show();
return a.exec();
}
//main.cpp
#include <QtGui/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setApplicationName("PhononTest");
MainWindow w;
w.setWindowTitle("Simple Player");
w.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
If I build it for x86 platform it works fine. But, if I compile it for ARMv5, it run with NO errors, but the window that contains the video loaded with "vP->load(Phonon::MediaSource("test256x144.avi"));" instruction stay blank also when I play it.
How to fix this issue?
NOTE 1: test256x144.avi is a mpeg movie, my qt embedded supports this codec, because "qDebug() << "phonon_supportedFormats:"<<phonon_supportedFormat s;" instruction returns:
phonon_supportedFormats: ("application/x-3gp", "application/x-bzip", "audio/x-alaw", "audio/x-au", "audio/x-it", "audio/x-m4a", "audio/x-mod", "audio/x-mulaw", "audio/x-nsf", "audio/x-s3m", "audio/x-stm", "audio/x-tta", "audio/x-ttafile", "audio/x-wav", "audio/x-xm", "multipart/x-mixed-replace", "text/x-cmml", "video/mpeg", "video/mpegts", "video/quicktime", "video/x-cdxa", "video/x-fli", "video/x-flv", "video/x-h264", "video/x-matroska", "video/x-msvideo", "video/x-mve", "video/x-nuv", "video/x-smoke", "video/x-vcd", "video/x-vmnc")
phonon_supportedFormats: ("application/x-3gp", "application/x-bzip", "audio/x-alaw", "audio/x-au", "audio/x-it", "audio/x-m4a", "audio/x-mod", "audio/x-mulaw", "audio/x-nsf", "audio/x-s3m", "audio/x-stm", "audio/x-tta", "audio/x-ttafile", "audio/x-wav", "audio/x-xm", "multipart/x-mixed-replace", "text/x-cmml", "video/mpeg", "video/mpegts", "video/quicktime", "video/x-cdxa", "video/x-fli", "video/x-flv", "video/x-h264", "video/x-matroska", "video/x-msvideo", "video/x-mve", "video/x-nuv", "video/x-smoke", "video/x-vcd", "video/x-vmnc")
To copy to clipboard, switch view to plain text mode
NOTE 2:I also played the movie with gstreamer (phonon use decodebin2 plugin to decode movies), and i can see it with no problem:
gst-launch-0.10 filesrc location=/mnt/mnt_gea/test256x144.avi ! decodebin2 ! ffmpegcolorspace ! 'video/x-raw-rgb,depth=16,bpp=16' ! fbdevsink device=/dev/fb0 sync=true
gst-launch-0.10 filesrc location=/mnt/mnt_gea/test256x144.avi ! decodebin2 ! ffmpegcolorspace ! 'video/x-raw-rgb,depth=16,bpp=16' ! fbdevsink device=/dev/fb0 sync=true
To copy to clipboard, switch view to plain text mode
This proves that gstreamer under phonon works properly and i have the codec installed properly
Bookmarks