Hello. I want to do a litte music player based on phonon libs.
I want to make another class with operations like play, stop etc.
#include "plik.h"
#include <QString>
#include <QDebug>
#include <phonon/Global>
#include <phonon/MediaObject>
#include <phonon/AudioOutput>
#include <phonon/MediaSource>
#include <phonon/Path>
Phonon::MediaObject *mediaObject;
Phonon::AudioOutput *audioOutput;
Plik::Plik()
{
this->next = NULL;
this->prev = NULL;
}
{
this->path = path;
return;
}
{
return this->path;
}
void Plik::playFile()
{
mediaObject = new Phonon::MediaObject(this);
audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory,this);
mediaObject->setCurrentSource(Phonon::MediaSource("/home/matulik/test.mp3"));
audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory,this);
Phonon::Path path = Phonon::createPath(mediaObject,audioOutput);
mediaObject->setTickInterval(1000);
audioOutput->setVolume(100);
audioOutput->setMuted(FALSE);
mediaObject->play();
}
#include "plik.h"
#include <QString>
#include <QDebug>
#include <phonon/Global>
#include <phonon/MediaObject>
#include <phonon/AudioOutput>
#include <phonon/MediaSource>
#include <phonon/Path>
Phonon::MediaObject *mediaObject;
Phonon::AudioOutput *audioOutput;
Plik::Plik()
{
this->next = NULL;
this->prev = NULL;
}
void Plik::setPath(QString path)
{
this->path = path;
return;
}
QString Plik::returnPath()
{
return this->path;
}
void Plik::playFile()
{
mediaObject = new Phonon::MediaObject(this);
audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory,this);
mediaObject->setCurrentSource(Phonon::MediaSource("/home/matulik/test.mp3"));
audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory,this);
Phonon::Path path = Phonon::createPath(mediaObject,audioOutput);
mediaObject->setTickInterval(1000);
audioOutput->setVolume(100);
audioOutput->setMuted(FALSE);
mediaObject->play();
}
To copy to clipboard, switch view to plain text mode
And in mainwindow:
Plik p1;
p1.playFile();
Plik p1;
p1.playFile();
To copy to clipboard, switch view to plain text mode
And this doesnt work.
I dont know where is the problem, becouse the same source code coping to mainwindow works..
#include "odplayer.h"
#include "ui_odplayer.h"
#include "plik.h"
#include <QString>
#include <QDebug>
#include <phonon/Global>
#include <phonon/MediaObject>
#include <phonon/AudioOutput>
#include <phonon/MediaSource>
#include <phonon/Path>
Phonon::MediaObject *mediaObject;
Phonon::AudioOutput *audioOutput;
odplayer
::odplayer(QWidget *parent
) : ui(new Ui::odplayer)
{
ui->setupUi(this);
mediaObject = new Phonon::MediaObject(this);
audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory,this);
mediaObject->setCurrentSource(Phonon::MediaSource("/home/matulik/test.mp3"));
audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory,this);
Phonon::Path path = Phonon::createPath(mediaObject,audioOutput);
mediaObject->setTickInterval(1000);
audioOutput->setVolume(100);
audioOutput->setMuted(FALSE);
mediaObject->play();
}
odplayer::~odplayer()
{
delete ui;
}
#include "odplayer.h"
#include "ui_odplayer.h"
#include "plik.h"
#include <QString>
#include <QDebug>
#include <phonon/Global>
#include <phonon/MediaObject>
#include <phonon/AudioOutput>
#include <phonon/MediaSource>
#include <phonon/Path>
Phonon::MediaObject *mediaObject;
Phonon::AudioOutput *audioOutput;
odplayer::odplayer(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::odplayer)
{
ui->setupUi(this);
mediaObject = new Phonon::MediaObject(this);
audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory,this);
mediaObject->setCurrentSource(Phonon::MediaSource("/home/matulik/test.mp3"));
audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory,this);
Phonon::Path path = Phonon::createPath(mediaObject,audioOutput);
mediaObject->setTickInterval(1000);
audioOutput->setVolume(100);
audioOutput->setMuted(FALSE);
mediaObject->play();
}
odplayer::~odplayer()
{
delete ui;
}
To copy to clipboard, switch view to plain text mode
Someone can help?
Bookmarks