Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMediaPlayer and QMediaPlaylist - problem with next
Forum Updated to NodeBB v4.3 + New Features

QMediaPlayer and QMediaPlaylist - problem with next

Scheduled Pinned Locked Moved General and Desktop
16 Posts 2 Posters 6.1k Views 1 Watching
  • 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #3

    Hi,

    Please practice some patience. Allow at least 24 hours before bumping your own thread. People on this forum don't necessarily lives in the same time zone as you.

    That said, what do you mean by close ? The application just stops ? Crashes ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • M Offline
      M Offline
      maniek1310
      wrote on last edited by
      #4

      Crashes, I just click on the "Next"

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #5

        What does a run with the debugger tell you ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • M Offline
          M Offline
          maniek1310
          wrote on last edited by
          #6

          http://imageshack.com/a/img199/3483/1ljx.png

          Console : Rozpoczęto debugowanie
          QEventLoop: Cannot be used without QApplication
          QObject::connect: Cannot connect (null)::aboutToQuit() to QNativeWifiEngine::closeHandle()

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #7

            How does your main.cpp look like ?

            Also, why make player and playlist static ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • M Offline
              M Offline
              maniek1310
              wrote on last edited by
              #8

              main.cpp
              @#include "mainwindow.h"
              #include <QApplication>

              int main(int argc, char *argv[])
              {
              QApplication a(argc, argv);
              MainWindow w;
              w.show();

              return a.exec&#40;&#41;;
              

              }
              @

              mainwindow.h
              @#ifndef MAINWINDOW_H
              #define MAINWINDOW_H

              #include <QMainWindow>

              namespace Ui {
              class MainWindow;
              }

              class MainWindow : public QMainWindow
              {
              Q_OBJECT

              public:
              explicit MainWindow(QWidget *parent = 0);
              ~MainWindow();

              private slots:
              void on_pushButton_clicked();

              void on_pushButton_2_clicked();
              
              void on_horizontalSlider_sliderMoved(int position);
              
              void aktualna_pozycja(qint64 position);
              
              void on_pushButton_3_clicked();
              
              void run_file&#40;QString file&#41;;
              
              void on_pause_clicked();
              
              void on_next_file_clicked();
              
              void on_pushButton_4_clicked();
              

              private:
              Ui::MainWindow *ui;
              };

              #endif // MAINWINDOW_H
              @

              test_sound.pro
              @#-------------------------------------------------

              Project created by QtCreator 2014-02-04T19:08:13

              #-------------------------------------------------

              QT += core gui
              QT += widgets multimedia
              QT += multimedia
              QT += core gui multimedia

              greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

              TARGET = test_sound
              TEMPLATE = app

              SOURCES += main.cpp
              mainwindow.cpp

              HEADERS += mainwindow.h

              FORMS += mainwindow.ui
              @

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #9

                Looks right.

                Please move both player and playlist has non static member variable of MainWindow and try again

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  maniek1310
                  wrote on last edited by
                  #10

                  I do not understand. I could explain it somehow differently?

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #11

                    @QMediaPlayer *player = new QMediaPlayer();
                    QMediaPlaylist *playlist = new QMediaPlaylist;@

                    These are static, remove them. And add two member variable in MainWindow to replace them.

                    @mainwindow.h
                    class MainWindow : public QMainWindow {
                    …

                    private:
                    QMediaPlayer *_player;
                    QMediaPlaylist *_playlist;

                    }

                    mainwindow.cpp

                    MainWindow::MainWindow(QWidget *parent) :
                    QMainWindow(parent),
                    ui(new Ui::MainWindow),
                    _player(new QMediaPlayer),
                    _playlist(new QMediaPlayList)
                    {
                    ui->setupUi(this);

                    QObject::connect(_player, SIGNAL(positionChanged(qint64)), this, SLOT(aktualna_pozycja(qint64)));
                    

                    }
                    @

                    Something like that

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      maniek1310
                      wrote on last edited by
                      #12

                      @mainwindow.h
                      ...
                      private:
                      Ui::MainWindow *ui;
                      QMediaPlayer *player;
                      QMediaPlayer *playlist;
                      };@

                      @mainwindow.cpp
                      ...
                      MainWindow::MainWindow(QWidget *parent) :
                      QMainWindow(parent),
                      ui(new Ui::MainWindow),
                      player(new QMediaPlayer),
                      playlist(new QMediaPlaylist)
                      {
                      ui->setupUi(this);

                      QObject::connect(player, SIGNAL(positionChanged(qint64)), this, SLOT(aktualna_pozycja(qint64)));
                      

                      }
                      ...
                      @

                      błąd: cannot convert 'QMediaPlaylist*' to 'QMediaPlayer*' in initialization
                      playlist(new QMediaPlaylist)

                      błąd: 'class QMediaPlayer' has no member named 'addMedia' playlist->addMedia(QUrl::fromLocalFile(file));

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #13

                        The error is pretty clear, you declared playlist list as a QMediaPlayer and not QMediaPlayList.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          maniek1310
                          wrote on last edited by
                          #14

                          Okay, thank you. Now the program compiles correctly, but it is still the same problem.

                          After pressing the "Next" button shows up is:

                          http://imageshack.com/a/img577/9630/0p87.png

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #15

                            Run your program using the debugger, that should catch the problem

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            0
                            • M Offline
                              M Offline
                              maniek1310
                              wrote on last edited by
                              #16

                              http://imageshack.com/a/img199/3483/1ljx.png

                              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