Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [Solved] .mp3 with Qt
Forum Updated to NodeBB v4.3 + New Features

[Solved] .mp3 with Qt

Scheduled Pinned Locked Moved QML and Qt Quick
19 Posts 4 Posters 11.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.
  • S Offline
    S Offline
    spode
    wrote on last edited by
    #5

    I need to use this application on windows...

    1 Reply Last reply
    0
    • S Offline
      S Offline
      spode
      wrote on last edited by
      #6

      how to run .mp3 in Qt? Otherwise, how to open them with the default program (Media player and other)?

      Edit: This was posted as a separate topic, but it clearly belongs to this topic; Andre

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #7

        If you want to open the MP3 in the default application, just use something like this:

        @
        QUrl mp3Url = QUrl::fromLocalFile(theMp3FileName); //assuming you want to play a local file
        QDesktopServices::openUrl(mp3Url);
        @

        1 Reply Last reply
        0
        • S Offline
          S Offline
          spode
          wrote on last edited by
          #8

          0k. it starts, so thank you, but there is a problem: relative url dows not start..

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #9

            Could you try if it works if you use a full path to the file, instead of a relative one?

            1 Reply Last reply
            0
            • S Offline
              S Offline
              spode
              wrote on last edited by
              #10

              yes, from full path it start.
              @ QUrl mp3Url = QUrl::fromLocalFile("../qml/fileTrenner2/compleanno.mp3");
              QDesktopServices::openUrl(mp3Url);
              @ with relative path it does not start...

              1 Reply Last reply
              0
              • L Offline
                L Offline
                loladiro
                wrote on last edited by
                #11

                Make sure your relative path is relative to "QDir::current()":http://doc.qt.nokia.com/4.7/qdir.html#current is. If it isn't you can always use
                @QDir(QCoreApplication::applicationDirPath ()).absoulteFilePath("/path/")@

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  spode
                  wrote on last edited by
                  #12

                  thank you. @
                  QString s = QDir::current().absolutePath().append("/qml/fileTrenner2/compleanno.mp3");
                  QUrl mp3Url = QUrl::fromLocalFile(s);
                  QDesktopServices::openUrl(mp3Url); @
                  this snippet starts!

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    loladiro
                    wrote on last edited by
                    #13

                    If I were you I'd still use applicationDirPath, because the working directory usually changes throughout your application and you cannot be sure that it points to where you want it to point.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      spode
                      wrote on last edited by
                      #14

                      i have this snippet:
                      @ QString s = QDir::current().absolutePath().append("/qml/fileTrenner2/compleanno.mp3");
                      QUrl mp3Url = QUrl::fromLocalFile(s);
                      QDesktopServices::openUrl(mp3Url); @
                      i want that the new window opens itself in minimized mode...or i want to move it.
                      how to do it?

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        spode
                        wrote on last edited by
                        #15

                        so, ideas for fixing?

                        1 Reply Last reply
                        0
                        • L Offline
                          L Offline
                          loladiro
                          wrote on last edited by
                          #16

                          If you just want to play a mp3 file, I ask you to use $yourFavoriteSearchEngine. There are plenty of threads on the internet dealing with that.

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            andre
                            wrote on last edited by
                            #17

                            As loladiro suggested: use applicationDirPath.

                            1 Reply Last reply
                            0
                            • L Offline
                              L Offline
                              loladiro
                              wrote on last edited by
                              #18

                              I think you can figure it out yourself. I am happy to give you tips, but I'm not going to write your app for you (or even parts of it).

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                spode
                                wrote on last edited by
                                #19

                                ahahah that is true! so, thanks!

                                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