Fixing the rowCount and colCount methods
[soundwave.git] / player.cpp
blob8c4bd8a765eafe8aeded9af4105e53a9b24e3452
1 #include "player.h"
2 #include <QProcess>
3 #include <QProcessEnvironment>
4 #include <QTemporaryFile>
6 //=========================================================
7 Player::Player(QUrl url)
9 arg = url.toString();
10 stop_flag = 0;
12 //=========================================================
13 Player::Player(QByteArray song)
15 file.open();
16 file.write( song );
18 arg = file.fileName();
19 stop_flag = 0;
22 //=========================================================
23 void Player::stop()
25 stop_flag = 1;
26 wait( -1 );
28 //=========================================================
29 void Player::run()
31 p = new QProcess();
32 QProcessEnvironment env = p->processEnvironment();
33 if( env.contains( "http_proxy" ))
34 env.remove( "http_proxy" );
35 p->setProcessEnvironment( env );
36 p->start( "mplayer", QStringList() << arg );
37 p->waitForStarted( -1 );
39 while( !stop_flag ){
40 while( p->canReadLine())
41 qDebug( "mplayer: %s", p->readLine().constData());
43 if( p->waitForFinished( 250 ))
44 break;
47 p->terminate();
48 delete p;