In the header define the following
private:
QPointer <QMediaPlayer> mp3backgroundplayer;
signals:
void playmp3background();
void stopmp3background();
private:
QPointer <QMediaPlayer> mp3backgroundplayer;
signals:
void playmp3background();
void stopmp3background();
To copy to clipboard, switch view to plain text mode
in the code use this to load it from the resource file
QPointer <QMediaPlayer> mp3backgroundplayer
= new QMediaPlayer
(this);
// ...
mp3backgroundplayer
->setMedia
(QUrl("qrc:/spacegame/images/gamemedia/spacegamebackground.mp3"));
mp3backgroundplayer->setVolume(30);
mp3backgroundplayer->l
mp3backgroundplayer->play();
connect(this,SIGNAL(playmp3background()),mp3backgroundplayer.data(),SLOT(play()));
connect(this, SIGNAL(stopmp3background()), mp3backgroundplayer.data(), SLOT(stop()));
QPointer <QMediaPlayer> mp3backgroundplayer = new QMediaPlayer (this);
// ...
mp3backgroundplayer->setMedia(QUrl("qrc:/spacegame/images/gamemedia/spacegamebackground.mp3"));
mp3backgroundplayer->setVolume(30);
mp3backgroundplayer->l
mp3backgroundplayer->play();
connect(this,SIGNAL(playmp3background()),mp3backgroundplayer.data(),SLOT(play()));
connect(this, SIGNAL(stopmp3background()), mp3backgroundplayer.data(), SLOT(stop()));
To copy to clipboard, switch view to plain text mode
to stop use this
this.emit(stopmp3background());
this.emit(stopmp3background());
To copy to clipboard, switch view to plain text mode
good luck
Bookmarks