[Solved] .mp3 with Qt
-
how to play a music file with Qt? i need to run a .mp3 one and .wav ones are too heavy! QML is better...
-
Hi spode, have a look at Multimedia QML Plugin, i think that's what you want.:D
@
import Qt 4.7
import QtMultimediaKit 1.1
...Audio { id: playMusic source: "music.wav" } MouseArea { id: playArea anchors.fill: parent onPressed: { playMusic.play() } }
@
-
@ not installed
import QtMultimediaKit 1.1
^ @ this is my error. however, .wav are too heavy, so i am triing for another format's support -
[quote author="spode" date="1308212238"][code]not installed
import QtMultimediaKit 1.1
^ [/code] this is my error. however, .wav are too heavy, so i am triing for another format's support[/quote]MP3 or Ogg is also be supportted.
The not installed error means you didn't install(make&make install) the corresponding plugin/lib. If you target in Windows/Linux/Mac, you need compile the Qt Mobility by yourself to enable using it.
-
I need to use this application on windows...
-
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
-
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);
@ -
0k. it starts, so thank you, but there is a problem: relative url dows not start..
-
Could you try if it works if you use a full path to the file, instead of a relative one?
-
yes, from full path it start.
@ QUrl mp3Url = QUrl::fromLocalFile("../qml/fileTrenner2/compleanno.mp3");
QDesktopServices::openUrl(mp3Url);
@ with relative path it does not start... -
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/")@ -
thank you. @
QString s = QDir::current().absolutePath().append("/qml/fileTrenner2/compleanno.mp3");
QUrl mp3Url = QUrl::fromLocalFile(s);
QDesktopServices::openUrl(mp3Url); @
this snippet starts! -
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.
-
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? -
so, ideas for fixing?
-
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.
-
As loladiro suggested: use applicationDirPath.
-
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).
-
ahahah that is true! so, thanks!