Results 1 to 2 of 2

Thread: Integrating Mplayer inside Qt Tab

  1. #1

    Default Integrating Mplayer inside Qt Tab

    I am trying to integrate Mplayer into a TAB how ever I am not getting the Black screen of the player I am getting only the silders





    Qt Code:
    1. #include <QtGui>
    2. #include <QDebug>
    3. #include <string>
    4.  
    5. #include "tabdialog.h"
    6. #include <QIcon>
    7. #include "qmpwidget.h"
    8. #include <QFileDialog>
    9. #include <QGridLayout>
    10. #include <QShowEvent>
    11. #include <QSlider>
    12. QString file;
    13. #include<QVBoxLayout>
    14. #include<QHBoxLayout>
    15.  
    16.  
    17. // Custom player
    18. class Player : public QMPwidget
    19. {
    20. // Q_OBJECT
    21.  
    22. public:
    23. Player(const QStringList &args, const QString &url, QWidget *parent = 0)
    24. : QMPwidget(parent), m_url(url)
    25. {
    26. connect(this, SIGNAL(stateChanged(int)), this, SLOT(stateChanged(int)));
    27. QMPwidget::start(args);
    28. }
    29.  
    30. private slots:
    31. void stateChanged(int state)
    32. {
    33. if (state == QMPwidget::NotStartedState) {
    34. QApplication::exit();
    35. } else if (state == QMPwidget::PlayingState && mediaInfo().ok) {
    36. if (parentWidget()) {
    37. parentWidget()->resize(mediaInfo().size.width(), mediaInfo().size.height());
    38. } else {
    39. resize(mediaInfo().size.width(), mediaInfo().size.height());
    40. }
    41. }
    42. }
    43.  
    44. protected:
    45. void showEvent(QShowEvent *event)
    46. {
    47. if (!event->spontaneous() && state() == QMPwidget::IdleState) {
    48. QMPwidget::load(m_url);
    49. }
    50. }
    51.  
    52. void keyPressEvent(QKeyEvent *event)
    53. {
    54. if (event->key() == Qt::Key_O) {
    55. QString url = QFileDialog::getOpenFileName(this, tr("Play media file..."));
    56. if (!url.isEmpty()) {
    57. m_url = url;
    58. QMPwidget::load(m_url);
    59. }
    60. } else {
    61. QMPwidget::keyPressEvent(event);
    62. }
    63. }
    64.  
    65. private:
    66. QString m_url;
    67. };
    To copy to clipboard, switch view to plain text mode 










    Qt Code:
    1. TabDialog::TabDialog(const QString &fileName, QWidget *parent)
    2. : QDialog(parent)
    3. {
    4. QFileInfo fileInfo(fileName);
    5.  
    6. tabWidget = new QTabWidget;
    7. tabWidget->addTab(new GeneralTab(fileInfo), tr("Multimedia"));
    8. tabWidget->addTab(new PermissionsTab(fileInfo), tr("TERMINAL MODE"));
    9. tabWidget->addTab(new ApplicationsTab(fileInfo), tr("NAVIGATION"));
    10.  
    11. buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
    12. | QDialogButtonBox::Cancel);
    13.  
    14. connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    15. connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
    16.  
    17. QVBoxLayout *mainLayout = new QVBoxLayout;
    18. mainLayout->addWidget(tabWidget);
    19. // mainLayout->addWidget(buttonBox);
    20. setLayout(mainLayout);
    21.  
    22. setWindowTitle(tr("Tab Dialog"));
    23. }
    24.  
    25.  
    26. GeneralTab::GeneralTab(const QFileInfo &fileInfo, QWidget *parent): QWidget(parent)
    27. {
    28. /*QWidget widget;
    29.   QVBoxLayout *mainLayout = new QVBoxLayout();
    30.   openButton = new QPushButton();
    31.  
    32.   openButton->setIcon(QIcon("/home/satyam/Desktop/Tabs/open.png"));
    33.   openButton->setIconSize(QSize(100,100));
    34.   // openButton->setMinimumWidth(10);
    35.   openButton->setMinimumHeight(100);
    36.   //openButton->setMaximumHeight(100);
    37.   openButton->setMaximumWidth(100);
    38.  
    39.   QSlider seekSlider(Qt::Horizontal, &widget);
    40.   QSlider volumeSlider(Qt::Horizontal, &widget);
    41.  
    42.  
    43.   mainLayout->addWidget(&seekSlider);
    44.   mainLayout->addWidget(&volumeSlider);
    45.   mainLayout->addWidget(openButton);
    46.  
    47.   connect(openButton,SIGNAL(clicked()),this,SLOT(on_pushButton_clicked()),Qt::AutoConnection);
    48.  
    49.   setLayout(mainLayout);*/
    50.  
    51. QWidget widget;
    52.  
    53. QHBoxLayout layout;
    54.  
    55.  
    56. QPushButton *play =new QPushButton("play");
    57.  
    58. play->setMaximumWidth(40);
    59. QPushButton *pause =new QPushButton("pause");
    60. pause->setMaximumWidth(40);
    61.  
    62. QPushButton *stop =new QPushButton("stop");
    63.  
    64. QPushButton *quit =new QPushButton("quit");
    65.  
    66. layout.addWidget(play);
    67. layout.addWidget(pause);
    68. layout.addWidget(stop);
    69. layout.addWidget(quit);
    70. widget.setLayout(&layout);
    71.  
    72.  
    73.  
    74. //widget.setWindowFlags( Qt::CustomizeWindowHint );
    75.  
    76. //widget.showMaximized();
    77.  
    78.  
    79. }
    80.  
    81. PermissionsTab::PermissionsTab(const QFileInfo &fileInfo, QWidget *parent)
    82. : QWidget(parent)
    83. {
    84. QWidget widget;
    85.  
    86.  
    87. QVBoxLayout *mainlayout = new QVBoxLayout;
    88. QHBoxLayout *toplayout = new QHBoxLayout;
    89. QVBoxLayout *botmlayout = new QVBoxLayout;
    90.  
    91.  
    92. seekSlider =new QSlider(Qt::Horizontal);
    93. volumeSlider =new QSlider(Qt::Horizontal);
    94.  
    95.  
    96.  
    97. QStringList args = QApplication::arguments();
    98. QString url;
    99. args.pop_front();
    100. if (!args.isEmpty() && !args.last().startsWith("-")) {
    101. url = args.last();
    102. args.pop_back();
    103. }
    104.  
    105.  
    106. Player player(args, url, &widget);
    107. player.setVolumeSlider(volumeSlider);
    108. player.setSeekSlider(seekSlider);
    109.  
    110.  
    111.  
    112. toplayout->addWidget(seekSlider);
    113. toplayout->addWidget(volumeSlider);
    114.  
    115. botmlayout->addWidget(&player);
    116. botmlayout->addLayout(toplayout);
    117.  
    118. // mainlayout->addLayout(toplayout);
    119. mainlayout->addLayout(botmlayout);
    120. setLayout(mainlayout);
    121. }
    122.  
    123. ApplicationsTab::ApplicationsTab(const QFileInfo &fileInfo, QWidget *parent)
    124. : QWidget(parent)
    125. {
    126.  
    127. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 20th April 2012 at 13:50. Reason: missing [code] tags

  2. #2

    Default Re: Integrating Mplayer inside Qt Tab

    Project source code is available at

    http://www.2shared.com/file/sxDtXzjC/Tabs.html

    I am trying to add media player based on mplayer inti the TAB.

Similar Threads

  1. Playing mplayer inside QWidget
    By sinha.ashish in forum Qt Programming
    Replies: 21
    Last Post: 14th January 2011, 12:14
  2. playing mplayer within a Qwidget in windows environment
    By ag.sitesh in forum Qt Programming
    Replies: 5
    Last Post: 18th April 2008, 11:11
  3. QProcess+mPlayer+Aspect Ratio
    By IGHOR in forum Qt Programming
    Replies: 0
    Last Post: 22nd March 2008, 03:14
  4. To play mplayer in widget
    By Deepak Mishra in forum Qt Programming
    Replies: 1
    Last Post: 4th November 2007, 16:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.