Hello.
I'm writing a litte music-player based on Qt and Phonon.
Im using a double-linked list (writed by myself) to storage a data and information. First class, File, storage information about opened files:
#include "file.h"
//Phonon::MediaObject *mediaObject;
//Phonon::AudioOutput *audioOutput;
File::File()
{
this->next = 0;
this->prev = 0;
this->path_to_file = "";
this->fileName = "";
this->title = "";
}
{
this->path_to_file = path;
}
{
return this->path_to_file;
}
void File::playFile()
{
this->mediaObject = new Phonon::MediaObject(this);
this->mediaObject->setCurrentSource(this->returnPath());
this->audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory,this);
Phonon::Path path = Phonon::createPath(this->mediaObject,this->audioOutput);
this->mediaObject->play();
}
void File::stopFile()
{
this->mediaObject->stop();
}
void File::setFileName(QString path
) {
for(int i=0;i<path.length();i++)
{
if (path[i] == '/')
n = i+1;
}
for(int i=n;i<path.length();i++)
temp.append(path[i]);
this->fileName = temp;
}
{
return this->fileName;
}
File *File::Copy(File &f)
{
File * temp = new File();
temp->setFileName(f.returnFileName());
temp->setPath(f.returnPath());
temp->next = f.next;
temp->prev = f.prev;
return temp;
}
#include "file.h"
//Phonon::MediaObject *mediaObject;
//Phonon::AudioOutput *audioOutput;
File::File()
{
this->next = 0;
this->prev = 0;
this->path_to_file = "";
this->fileName = "";
this->title = "";
}
void File::setPath(QString path)
{
this->path_to_file = path;
}
QString File::returnPath()
{
return this->path_to_file;
}
void File::playFile()
{
this->mediaObject = new Phonon::MediaObject(this);
this->mediaObject->setCurrentSource(this->returnPath());
this->audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory,this);
Phonon::Path path = Phonon::createPath(this->mediaObject,this->audioOutput);
this->mediaObject->play();
}
void File::stopFile()
{
this->mediaObject->stop();
}
void File::setFileName(QString path)
{
int n = 0; QString temp = "";
for(int i=0;i<path.length();i++)
{
if (path[i] == '/')
n = i+1;
}
for(int i=n;i<path.length();i++)
temp.append(path[i]);
this->fileName = temp;
}
QString File::returnFileName()
{
return this->fileName;
}
File *File::Copy(File &f)
{
File * temp = new File();
temp->setFileName(f.returnFileName());
temp->setPath(f.returnPath());
temp->next = f.next;
temp->prev = f.prev;
return temp;
}
To copy to clipboard, switch view to plain text mode
And second class it's double-linked list.
I want to make a seekslider, but I have a little problem. I'm using mediaObject not in MainWindow, but in another class.
Something like this doesnt work (in MainWindow):
ss->setMediaObject(playlist->ReturnX(i)->mediaObject);
ss->setMediaObject(playlist->ReturnX(i)->mediaObject);
To copy to clipboard, switch view to plain text mode
I also can't make a function i File class that return a mediaObject.
Someone can help me how to resolve this problem??
Bookmarks