PDA

View Full Version : Getting access to SeekSlider from another class



matulik
3rd January 2013, 20:43
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 = "";
}

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;
}


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);

I also can't make a function i File class that return a mediaObject.

Someone can help me how to resolve this problem??

matulik
4th January 2013, 19:17
The best solution would be a function retunred mediaObject from File class. But I have problem with do this.
If I have a mediaObject as global variable or as public variable I can't do it.

Someone can help me with this problem?