Problem with QDir path to the folders
-
Not sure I understand all of your explanation. But I think
QStringList files = directory.entryList();
will be getting the file names as relative to the directory you set in
directory.setCurrent(path);
, i.e. plain names with no leading directory path (print them out to see this)? But your media player won't know that. Pass absolute paths to it, not plain file names? -
Not sure I understand all of your explanation. But I think
QStringList files = directory.entryList();
will be getting the file names as relative to the directory you set in
directory.setCurrent(path);
, i.e. plain names with no leading directory path (print them out to see this)? But your media player won't know that. Pass absolute paths to it, not plain file names?@JonB Yes, you right, it's prints only file names without directory path
-
@JonB Yes, you right, it's prints only file names without directory path
@Nick-Shapper
So there are many ways of making the path absolute. If you can't find a better one, you can always prependpath
to eachfilepath
in yourforeach
loop. -
@Nick-Shapper
So there are many ways of making the path absolute. If you can't find a better one, you can always prependpath
to eachfilepath
in yourforeach
loop.@JonB Ok, i guess i did something wrong. I changed
mediaPlaylist->addMedia(QUrl(filepath));
to
mediaPlaylist->addMedia(QUrl(filepath.prepend(path)));
Now it can't even start to play any file.
Also i printed out my filepath and it says this:
"C:/Users/Archivarius-cat/MusicMick Gordon - Bfg Division.mp3"
"C:/Users/Archivarius-cat/MusicMick Gordon - Damnation.mp3"
"C:/Users/Archivarius-cat/MusicMick Gordon - Uac Report File Shto36u3.mp3"from what i can see there's no / after Music folder, and it's weird. I'm gonna remove prepend function and see what it's gonna print without it
-
@JonB Ok, i guess i did something wrong. I changed
mediaPlaylist->addMedia(QUrl(filepath));
to
mediaPlaylist->addMedia(QUrl(filepath.prepend(path)));
Now it can't even start to play any file.
Also i printed out my filepath and it says this:
"C:/Users/Archivarius-cat/MusicMick Gordon - Bfg Division.mp3"
"C:/Users/Archivarius-cat/MusicMick Gordon - Damnation.mp3"
"C:/Users/Archivarius-cat/MusicMick Gordon - Uac Report File Shto36u3.mp3"from what i can see there's no / after Music folder, and it's weird. I'm gonna remove prepend function and see what it's gonna print without it
@Nick-Shapper addMedia( QUrl::fromLocalFile( m_fileName ) ) <==add them one after another with full path. Normally you need a filter to extract all files which can be played.
-
No, when i removed it it printed:
"Mick Gordon - Bfg Division.mp3"
"Mick Gordon - Damnation.mp3"
"Mick Gordon - Uac Report File Shto36u3.mp3
So i guess it was working -
@JonB Ok, i guess i did something wrong. I changed
mediaPlaylist->addMedia(QUrl(filepath));
to
mediaPlaylist->addMedia(QUrl(filepath.prepend(path)));
Now it can't even start to play any file.
Also i printed out my filepath and it says this:
"C:/Users/Archivarius-cat/MusicMick Gordon - Bfg Division.mp3"
"C:/Users/Archivarius-cat/MusicMick Gordon - Damnation.mp3"
"C:/Users/Archivarius-cat/MusicMick Gordon - Uac Report File Shto36u3.mp3"from what i can see there's no / after Music folder, and it's weird. I'm gonna remove prepend function and see what it's gonna print without it
@Nick-Shapper said in Problem with QDir path to the folders:
from what i can see there's no / after Music folder, and it's weird. I'm gonna remove prepend function and see what it's gonna print without it
When I said "prepend", I meant metaphorically! I didn't even know there was a
QString::prepend()
method. Yes you have to put the directory-separator-slash in. There are many ways to do path manipulation in Qt, sorry I don't have time to look them up for you. -
@Nick-Shapper said in Problem with QDir path to the folders:
from what i can see there's no / after Music folder, and it's weird. I'm gonna remove prepend function and see what it's gonna print without it
When I said "prepend", I meant metaphorically! I didn't even know there was a
QString::prepend()
method. Yes you have to put the directory-separator-slash in. There are many ways to do path manipulation in Qt, sorry I don't have time to look them up for you.@JonB Ok, thanks anyway, at least you gave me a direction :)
-
@JonB Ok, thanks anyway, at least you gave me a direction :)
@Nick-Shapper
This isn't the best, but kludged:mediaPlaylist->addMedia(QUrl(filepath.prepend("/").prepend(path))); // or mediaPlaylist->addMedia(QUrl(path + QString("/") + filepath)); // or mediaPlaylist->addMedia(QUrl(QString("%1/%2").arg(path).arg(filepath)));
?
-
@Nick-Shapper
This isn't the best, but kludged:mediaPlaylist->addMedia(QUrl(filepath.prepend("/").prepend(path))); // or mediaPlaylist->addMedia(QUrl(path + QString("/") + filepath)); // or mediaPlaylist->addMedia(QUrl(QString("%1/%2").arg(path).arg(filepath)));
?
@JonB I got it working, Thanks a lot you man, really appreciate your help!