SimoLab
3rd November 2013, 00:43
Hi everybody,
I created a reminder app that plays some mp3 files at specific times using QMediaPlayer an QMediaPlaylist. Those files are loaded in the playlist using relative paths. I added also the possibility to lunch the app by command line arguments at windows startup.
the problem is when the app is lunched at startup ( HKLM\...\Run) the mp3 files are not loaded in the playlist BUT when i add the app .exe shortcut with the same command line arguments to the startup folder (AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup) mp3 files are loaded and everything is OK...
Thanks for your help :rolleyes:
More informations:
directory structure:
9747
main.cpp
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
mainwindow w;
if (a.arguments().count() > 1)
{
QString arg1 = a.arguments().at(1);
if(arg1==QString("/boot"))
{
w.startUp();
}
}
else
w.show();
return a.exec();
loading files into playList:
{...}
player = new QMediaPlayer(this);
playList = new QMediaPlaylist();
playList->addMedia(QUrl::fromLocalFile("media/sound.mp3"));
playList->addMedia(QUrl::fromLocalFile("media/reminder.mp3"));
playList->setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
player->setPlaylist(playList);
{...}
startup function:
void mainwindow::startUp()
{
this->showMinimized();
this->hide();
trayIcon->show();
}
Added after 1 47 minutes:
Ok i solved the problem by using QCoreApplication::applicationDirPath () because when my app is started with windows the working directory changes to SysWOW64.
I created a reminder app that plays some mp3 files at specific times using QMediaPlayer an QMediaPlaylist. Those files are loaded in the playlist using relative paths. I added also the possibility to lunch the app by command line arguments at windows startup.
the problem is when the app is lunched at startup ( HKLM\...\Run) the mp3 files are not loaded in the playlist BUT when i add the app .exe shortcut with the same command line arguments to the startup folder (AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup) mp3 files are loaded and everything is OK...
Thanks for your help :rolleyes:
More informations:
directory structure:
9747
main.cpp
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
mainwindow w;
if (a.arguments().count() > 1)
{
QString arg1 = a.arguments().at(1);
if(arg1==QString("/boot"))
{
w.startUp();
}
}
else
w.show();
return a.exec();
loading files into playList:
{...}
player = new QMediaPlayer(this);
playList = new QMediaPlaylist();
playList->addMedia(QUrl::fromLocalFile("media/sound.mp3"));
playList->addMedia(QUrl::fromLocalFile("media/reminder.mp3"));
playList->setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
player->setPlaylist(playList);
{...}
startup function:
void mainwindow::startUp()
{
this->showMinimized();
this->hide();
trayIcon->show();
}
Added after 1 47 minutes:
Ok i solved the problem by using QCoreApplication::applicationDirPath () because when my app is started with windows the working directory changes to SysWOW64.