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. Problem with Timer in Media Player app
Qt 6.11 is out! See what's new in the release blog

Problem with Timer in Media Player app

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 2 Posters 2.7k Views 2 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.
  • Q Offline
    Q Offline
    Qinyx
    wrote on last edited by
    #1

    Hi,

    It is me again with my stupidity. When i finished my media player, with database of already played videos, i´ve got an idea, to add timer.

    I tried it 22 times, then i realised that i´ll need some help again.

    CODE: https://mega.nz/#F!SEhxkbTL!mA2yUpYqNFaglQZKhlsn2w

    Here is my code when you can see that media player is working really well, but there is no timer. I´ve created QLabel as permanent widget, and QTimer which starts when program starts. But that is it, that is wrong. I need to start timer when i start a video, and when it ends, timer have to stop.

    Problem is that I am not able to connect timer, label which will show that time, and video/music that will be played.

    If there is someone who is willing to help me :)

    I would be really greatful.

    Regards

    Qinyx

    ? 1 Reply Last reply
    0
    • Q Qinyx

      Hi,

      It is me again with my stupidity. When i finished my media player, with database of already played videos, i´ve got an idea, to add timer.

      I tried it 22 times, then i realised that i´ll need some help again.

      CODE: https://mega.nz/#F!SEhxkbTL!mA2yUpYqNFaglQZKhlsn2w

      Here is my code when you can see that media player is working really well, but there is no timer. I´ve created QLabel as permanent widget, and QTimer which starts when program starts. But that is it, that is wrong. I need to start timer when i start a video, and when it ends, timer have to stop.

      Problem is that I am not able to connect timer, label which will show that time, and video/music that will be played.

      If there is someone who is willing to help me :)

      I would be really greatful.

      Regards

      Qinyx

      ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      @Qinyx Ahoj! What's the purpose of the timer?

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        Qinyx
        wrote on last edited by
        #3

        Well, the purpose is that, when i start video i want from timer to show me on what minute video is, its full lenght etc. Something like this 00:00/15:53, you know, and it should be connected with that label which is going to show it right in the app.

        ? 1 Reply Last reply
        0
        • Q Qinyx

          Well, the purpose is that, when i start video i want from timer to show me on what minute video is, its full lenght etc. Something like this 00:00/15:53, you know, and it should be connected with that label which is going to show it right in the app.

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          @Qinyx But you don't need a timer for that, QMediaPlayer emits void positionChanged(qint64 position).

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            Qinyx
            wrote on last edited by
            #5

            Oh, I see .. well i dont know if i would be able to complete it either, but i will try :) Thanks for now :)

            Qinyx

            1 Reply Last reply
            0
            • Q Offline
              Q Offline
              Qinyx
              wrote on last edited by
              #6

              Well as I said, i am too unexperienced in this, so was not able to connect it to that label that has to shows it.

              ? 1 Reply Last reply
              0
              • Q Qinyx

                Well as I said, i am too unexperienced in this, so was not able to connect it to that label that has to shows it.

                ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                Add another member function to your main window:
                void onPlayerPositionChanged(qint64 position); // in header

                void MainWindow::onPlayerPositionChanged(qint64 position)
                {
                   const auto text = QString("Position: %1 ms").arg(position);
                   ui->yourLabel.setText(text);
                }
                

                Then connect the player's signal to this function :-)

                1 Reply Last reply
                2
                • Q Offline
                  Q Offline
                  Qinyx
                  wrote on last edited by
                  #8

                  Hi there,

                  i am sorry for late reply, i´ve had kynology competition. But i have been able to complete my project thanks to your help. I am really greatful.

                  There is my code for comparasing: https://mega.nz/#F!ndwmxDgJ!LoX2SUHA2wIkSaFSXbQntA

                  Thanks a lot again :)

                  Regards
                  Qinyx

                  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