Esempio n. 1
0
void PlayerController::CheckPlayerState()
{
RWsSession* iSession=new RWsSession();
iSession->Connect();
TApaTaskList lst(*iSession);
TApaTask tsk=lst.FindApp(KMusicPlayerAppUid);
TApaTask tsk2=lst.FindApp(KRadioUid);

if (tsk.Exists()){emit playerStarted(true);qDebug()<<"player started";}
if (tsk2.Exists())
{
    radioLaunched=true;
    emit playerStarted(false);
    qDebug()<<"radio started";
    int aValue;
    RProperty::Get(KFMRadioPSUid, KFMRadioPSDataFrequency,aValue);
    float freq=aValue/1e6;
    iStation.freq=freq;
    TBuf<255> name,rds,type;
    RProperty::Get(KFMRadioPSUid, KFMRadioPSDataChannelName,name);
    RProperty::Get(KFMRadioPSUid, KFMRadioPSDataRDSRadioText,rds);
    iStation.name=QString::fromRawData(reinterpret_cast<const QChar*>(name.Ptr()),name.Length());
    iStation.rds=QString::fromRawData(reinterpret_cast<const QChar*>(rds.Ptr()),rds.Length());
    QString line;
    if (iStation.name.length()>0) line=QString::fromUtf8(iStation.name.toUtf8().data());
    else if (iStation.rds.length()>0) line=QString::fromUtf8(iStation.rds.toUtf8().data());
    else line=QString::fromUtf8("FM Radio");
    changeTrackInfo(line,QString::number(iStation.freq,'f',2)+" MHz");
}
iSession->Close();
}
Esempio n. 2
0
void NoatunInterface::appRegistered(const QCString &appId)
{
	if (appId.contains("noatun",false))
	{
		mAppId = appId;
		emit playerStarted();
		mNoatunTimer->start(mTimerValue);
	}
}
Esempio n. 3
0
void PlayerController::ValChanged(TUid aUid, TUint32 aKey, TInt aValue)
{
if (aKey==KFMRadioPSDataRadioPowerState)
{
    if (aValue==EFMRadioPSRadioPowerOn&&(!radioLaunched))
    {
        radioLaunched=true;
        Close(KMusicPlayerAppUid);
        qDebug()<<"radio launched";
        emit playerStarted(false);
     }
     else if (aValue==EFMRadioPSRadioPowerOff&&radioLaunched)
     {
        radioLaunched=false;
        qDebug()<<"radio closed";
        emit playerClosed();
     }
}
else if (aKey==KFMRadioPSDataFrequency)
{
    float freq=aValue/1e6;
    iStation.freq=freq;
    qDebug()<<aValue<<radioLaunched;
    if (freq>50&&freq<200)
    {
        radioLaunched=true;
        Close(KMusicPlayerAppUid);
        qDebug()<<"radio launched";
        emit playerStarted(false);
    }
    if ((freq>200||freq<50)&&radioLaunched)
    {
        radioLaunched=false;
        qDebug()<<"radio closed";
        emit playerClosed();
    }
    QString line;
    if (iStation.name.length()>0) line=QString::fromUtf8(iStation.name.toUtf8().data());
    else if (iStation.rds.length()>0) line=QString::fromUtf8(iStation.rds.toUtf8().data());
    else line=QString::fromUtf8("FM Radio");
    if (radioLaunched)changeTrackInfo(line,QString::number(iStation.freq,'f',2)+" MHz");
}
}
Esempio n. 4
0
void NoatunInterface::myInit()
{
	// Start the timer if noatun is already running
	// Needed if user adds applet while running noatun
	if ( findRunningNoatun() )
	{
		emit playerStarted();
		mNoatunTimer->start(mTimerValue);
	}
	else
	{
		emit playerStopped();
		emit newSliderPosition(0,0);
	}
}
Esempio n. 5
0
void PlayerController::Tick()
{
    RWsSession* iSession=new RWsSession();
    iSession->Connect();
       TApaTaskList lst(*iSession);
       TApaTask tsk=lst.FindApp(KMusicPlayerAppUid);
       TApaTask tsk2=lst.FindApp(KRadioUid);
       if (tsk.Exists())
       {
           if (!playerLaunched)
           {
               emit playerStarted(true);
               playerLaunched=true;
               qDebug()<<"Player launched";
               Close(KRadioUid);
               iPlayer->RequestMediaL();
           }
       }
       else
       {
           if (playerLaunched)
           {
               if (!radioLaunched) emit playerClosed();
               playerLaunched=false;
               qDebug()<<"Player closed";
               checkTimer->stop();
           }
       }

       if (!tsk2.Exists())
       {
           if (radioLaunched)
           {
               if (!playerLaunched) emit playerClosed();
               radioLaunched=false;
               qDebug()<<"radio closed";
               checkTimer->stop();
           }
       }
       iSession->Close();
}
int PlayerController::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: playing(); break;
        case 1: stopped(); break;
        case 2: paused(); break;
        case 3: playerStarted((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 4: playerClosed(); break;
        case 5: changeTrackInfo((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 6: changePos((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 7: passAlbumArt((*reinterpret_cast< CFbsBitmap*(*)>(_a[1]))); break;
        case 8: updateAlbumArt((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 9: CheckPlayerState(); break;
        case 10: Tick(); break;
        case 11: Play(); break;
        case 12: Pause(); break;
        case 13: Next(); break;
        case 14: Previous(); break;
        case 15: SeekForward(); break;
        case 16: SeekBack(); break;
        case 17: StopSeeking(); break;
        case 18: AlbumArtSaved((*reinterpret_cast< CFbsBitmap*(*)>(_a[1]))); break;
        case 19: GoToNowPlaying(); break;
        case 20: ClosePlayer(); break;
        case 21: SeekToPos((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 22: GetState(); break;
        default: ;
        }
        _id -= 23;
    }
    return _id;
}
Esempio n. 7
0
void MediaControl::reparseConfig()
{
//	kdDebug(90200) << "reparseConfig();" << endl;
    _configFrontend->reparseConfiguration();

    if (_player != 0L) // make sure there is no player-object
    {
        _player->disconnect(); // disconnect from all things

        time_slider->disconnect();
        prev_button->disconnect();
        playpause_button->disconnect();
        stop_button->disconnect();
        next_button->disconnect();

        delete slider_tooltip; // tooltip depends on _player : delete it before _player gets deleted
        slider_tooltip = 0L;

        delete _player;
        _player = 0L;
    }

    mLastLen = -1;
    mLastTime = -1;
    mLastStatus = -1;

    QString playerString = _configFrontend->player();


#ifdef HAVE_XMMS
    if (playerString == "XMMS")
    {
        _player = new XmmsInterface ();
        time_slider->setSteps((_configFrontend->mouseWheelSpeed()*1000),
                              (_configFrontend->mouseWheelSpeed()*1000));
    }
    else
#endif
        if (playerString == "JuK")
        {
            _player = new JuKInterface();
            time_slider->setSteps((_configFrontend->mouseWheelSpeed()),
                                  (_configFrontend->mouseWheelSpeed()));
        }
        else if (playerString == "Amarok")
        {
            _player = new AmarokInterface();
            time_slider->setSteps((_configFrontend->mouseWheelSpeed()),
                                  (_configFrontend->mouseWheelSpeed()));
        }
        else if (playerString == "KsCD")
        {
            _player = new KsCDInterface();
            time_slider->setSteps((_configFrontend->mouseWheelSpeed()),
                                  (_configFrontend->mouseWheelSpeed()));
        }
        else if (playerString == "mpd")
        {
            _player = new MpdInterface();
            time_slider->setSteps((_configFrontend->mouseWheelSpeed()),
                                  (_configFrontend->mouseWheelSpeed()));
        }
        else // Fallback is Noatun
        {
            _player = new NoatunInterface();
            time_slider->setSteps((_configFrontend->mouseWheelSpeed()),
                                  (_configFrontend->mouseWheelSpeed()));
        }

    //  this signal gets emitted by a playerInterface when the player's playtime changed
    connect(_player, SIGNAL(newSliderPosition(int,int)),
            this, SLOT(setSliderPosition(int,int)));

    connect(_player, SIGNAL(playerStarted()), SLOT(enableAll()));
    connect(_player, SIGNAL(playerStopped()), SLOT(disableAll()));
    connect(_player, SIGNAL(playingStatusChanged(int)), SLOT(slotPlayingStatusChanged(int)));

    // do we use our icons or the default ones from KDE?
    if(_configFrontend->useCustomTheme())
    {
        // load theme
        QString skindir = locate("data", "mediacontrol/"+_configFrontend->theme()+"/");

        // the user has to take care if all pixmaps are there, we only check for one of them
        if (QFile(skindir+"play.png").exists())
        {
            prev_button->setIconSet(SmallIconSet(locate("data",skindir+"prev.png")));
            if (_player->playingStatus() == PlayerInterface::Playing)
                playpause_button->setIconSet(SmallIconSet(locate("data",skindir+"play.png")));
            else
                playpause_button->setIconSet(SmallIconSet(locate("data",skindir+"pause.png")));
            stop_button->setIconSet(SmallIconSet(locate("data",skindir+"stop.png")));
            next_button->setIconSet(SmallIconSet(locate("data",skindir+"next.png")));
        }
        else // icon-theme is invalid or not there
        {
            KNotifyClient::event(winId(), KNotifyClient::warning,
                                 i18n("There was trouble loading theme %1. Please choose" \
                                      " a different theme.").arg(skindir));

            // default to kde-icons, they have to be installed :)
            slotIconChanged();

            // and open prefs-dialog
            preferences();
        }
    }
    else // KDE default-icons, assuming that these icons exist!
    {
        // sets icons from kde
        slotIconChanged();
    }

    slider_tooltip = new MediaControlToolTip(time_slider, _player);

    connect(prev_button, SIGNAL(clicked()), _player, SLOT(prev()));
    connect(playpause_button, SIGNAL(clicked()), _player, SLOT(playpause()));
    connect(stop_button, SIGNAL(clicked()), _player, SLOT(stop()));
    connect(next_button, SIGNAL(clicked()), _player, SLOT(next()));

    connect(time_slider, SIGNAL(sliderPressed()), _player, SLOT(sliderStartDrag()));
    connect(time_slider, SIGNAL(sliderReleased()), _player, SLOT(sliderStopDrag()));
    connect(time_slider, SIGNAL(valueChanged(int)), this, SLOT(adjustTime(int)));
    connect(time_slider, SIGNAL(volumeUp()), _player, SLOT(volumeUp()));
    connect(time_slider, SIGNAL(volumeDown()), _player, SLOT(volumeDown()));
    connect(this, SIGNAL(newJumpToTime(int)), _player, SLOT(jumpToTime(int)));
}