2 #include <phonon/MediaSource>
4 using namespace SomePlayer::Playback;
5 using namespace SomePlayer::DataObjects;
7 Player::Player(QObject *parent) :
13 void Player::setTrack(Track &track) {
14 _current_track = track;
16 emit stateChanged(PLAYER_LOADING);
22 emit stateChanged(PLAYER_PLAYING);
29 emit stateChanged(PLAYER_STOPPED);
33 void Player::pause() {
36 emit stateChanged(PLAYER_PAUSED);
40 void Player::_create_player() {
42 disconnect(_player, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(_stateChanged(Phonon::State,Phonon::State)));
45 _player = Phonon::createPlayer(Phonon::MusicCategory, Phonon::MediaSource(_current_track.source()));
46 _player->setTickInterval(1000);
47 connect(_player, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(_stateChanged(Phonon::State,Phonon::State)));
48 connect(_player, SIGNAL(tick(qint64)), this, SLOT(_tick(qint64)));
49 emit stateChanged(PLAYER_STOPPED);
52 void Player::_stateChanged(Phonon::State newState, Phonon::State oldState) {
55 void Player::_tick(qint64 ticks) {
56 emit tick(ticks/1000, _current_track.metadata().length());