#include "example.h"

#include <QtGui/QLabel>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
#include <QtGui/QAction>
#include <QtGui/QToolBar>
#include <phonon/mediaobject.h>
#include <phonon/audiooutput.h>
#include <phonon/videowidget.h>
#include <QFileDialog>
#include <QDockWidget>
#include <QListView>

Example::Example()
{
	QToolBar* tools=addToolBar("Controls");
	tools->addAction("Open", this, SLOT(selectFile()));
	tools->addAction("Play/Pause", this, SLOT(play()));
	tools->addAction("Stop", this, SLOT(stop()));
	
	mediaObject = new Phonon::MediaObject(this);
	
	Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
	Phonon::Path path = Phonon::createPath(mediaObject, audioOutput);
	
	Phonon::VideoWidget *vwidget = new Phonon::VideoWidget(this);
	Phonon::createPath(mediaObject, vwidget);
	
	connect(mediaObject, SIGNAL(finished()), SLOT(finished()));
	
	setCentralWidget(vwidget);
}

Example::~Example()
{}

void Example::selectFile()
{
	QString file=QFileDialog::getOpenFileName(this, "Open a file to reproduce", QString(), QString("Media (*.mp3 *.avi)"));
	mediaObject->setCurrentSource(file);
	mediaObject->play();
}

void Example::play()
{
	if(mediaObject->state()==Phonon::PlayingState)
		mediaObject->pause();
	else
		mediaObject->play();
}

void Example::stop()
{
	mediaObject->stop();
}

void Example::finished()
{}

#include "example.moc"
