void
ScrobbleService::setConnection(PlayerConnection*c)
{
    if( m_connection )
    {
        // disconnect from all the objects that we connect to below
        disconnect( m_connection, 0, this, 0);
        if(m_watch)
            m_connection->setElapsed(m_watch->elapsed());
    }

    //
    connect(c, SIGNAL(trackStarted(Track, Track)), SLOT(onTrackStarted(Track, Track)));
    connect(c, SIGNAL(paused()), SLOT(onPaused()));
    connect(c, SIGNAL(resumed()), SLOT(onResumed()));
    connect(c, SIGNAL(stopped()), SLOT(onStopped()));

    connect(c, SIGNAL(trackStarted(Track, Track)), SIGNAL(trackStarted(Track, Track)));
    connect(c, SIGNAL(resumed()), SIGNAL(resumed()));
    connect(c, SIGNAL(paused()), SIGNAL(paused()));
    connect(c, SIGNAL(stopped()), SIGNAL(stopped()));
    connect(c, SIGNAL(bootstrapReady(QString)), SIGNAL( bootstrapReady(QString)));

    m_connection = c;

    if(c->state() == Playing || c->state() == Paused)
        c->forceTrackStarted(Track());

    if( c->state() == Paused )
        c->forcePaused();
}
ScrobblesListWidget::ScrobblesListWidget( QWidget* parent )
    :QListWidget( parent ), m_trackItem( 0 )
{
    setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );

#ifdef Q_OS_MAC
    connect( verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(scroll()) );
#endif

    setAttribute( Qt::WA_MacNoClickThrough );
    setAttribute( Qt::WA_MacShowFocusRect, false );

    setUniformItemSizes( false );
    setSortingEnabled( false );
    setSelectionMode( QAbstractItemView::NoSelection );
    setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );

    connect( qApp, SIGNAL( sessionChanged(unicorn::Session)), SLOT(onSessionChanged(unicorn::Session)));

    connect( &ScrobbleService::instance(), SIGNAL(scrobblesCached(QList<lastfm::Track>)), SLOT(onScrobblesSubmitted(QList<lastfm::Track>) ) );
    connect( &ScrobbleService::instance(), SIGNAL(scrobblesSubmitted(QList<lastfm::Track>)), SLOT(onScrobblesSubmitted(QList<lastfm::Track>) ) );

    connect( &ScrobbleService::instance(), SIGNAL(trackStarted(lastfm::Track,lastfm::Track)), SLOT(onTrackStarted(lastfm::Track,lastfm::Track)));
    connect( &ScrobbleService::instance(), SIGNAL(paused()), SLOT(onPaused()));
    connect( &ScrobbleService::instance(), SIGNAL(resumed()), SLOT(onResumed()));
    connect( &ScrobbleService::instance(), SIGNAL(stopped()), SLOT(onStopped()));

    onSessionChanged( aApp->currentSession() );
}
Ejemplo n.º 3
0
int ItemSequencerI::onNotify(int msg, int param1, int param2) {
  switch (msg) {
    case SEQNOTIFY_ONREGISTER: return onRegister();
    case SEQNOTIFY_ONDEREGISTER: return onDeregister();
    case SEQNOTIFY_ONNEXTFILE: return onNextFile();
    case SEQNOTIFY_ONTITLECHANGE: return onTitleChange();
    case SEQNOTIFY_ONSTARTED: return onStarted();
    case SEQNOTIFY_ONSTOPPED: return onStopped();
    case SEQNOTIFY_ONPAUSED: return onPaused();
    case SEQNOTIFY_ONUNPAUSED: return onUnpaused();
  }
  return 0;
}
void LinkLocalServiceBrowser::stop() {
	assert(isRunning());
	if (isRegistered()) {
		unregisterService();
	}
	for (ResolveQueryMap::const_iterator i = resolveQueries.begin(); i != resolveQueries.end(); ++i) {
		i->second->stop();
	}
	resolveQueries.clear();
	services.clear();
	browseQuery->stopBrowsing();
	browseQuery.reset();
	onStopped(haveError);
}
Ejemplo n.º 5
0
void tcClientCtrl::initialize(QString config_file)
{
    gst_init(NULL, NULL);
	msConfigFile = config_file;

	mpTray = new tcSystemTray(this);
	mpTray->initialize();
	connect(this, SIGNAL(started()), mpTray, SLOT(onStarted()));
	connect(this, SIGNAL(stopped()), mpTray, SLOT(onStopped()));
	mpTray->writeToolTip("Addintool: Stopped");

	start();
    qDebug() << "tcClientCtrl Initialized";
}
NowPlayingWidget::NowPlayingWidget(QWidget *parent)
    :QWidget(parent)
{
    QVBoxLayout* layout = new QVBoxLayout( this );
    layout->setContentsMargins( 0, 0, 0, 0 );
    layout->setSpacing( 0 );

    layout->addWidget( ui.playbackControls = new PlaybackControlsWidget( this ) );

    layout->addStretch( 1 );

    connect( &RadioService::instance(), SIGNAL(tuningIn(RadioStation)), SLOT(onTuningIn(RadioStation)) );

    connect( &ScrobbleService::instance(), SIGNAL(trackStarted(Track,Track)), SLOT(onTrackStarted(Track,Track)) );
    connect( &ScrobbleService::instance(), SIGNAL(stopped()), SLOT(onStopped()) );
}
PlaybackControlsWidget::PlaybackControlsWidget(QWidget *parent) :
    StylableWidget(parent),
    ui(new Ui::PlaybackControlsWidget),
    m_scrobbleTrack( false )
{
    ui->setupUi(this);

    ui->play->setAttribute( Qt::WA_LayoutUsesWidgetRect );
    ui->ban->setAttribute( Qt::WA_LayoutUsesWidgetRect );
    ui->love->setAttribute( Qt::WA_LayoutUsesWidgetRect );
    ui->skip->setAttribute( Qt::WA_LayoutUsesWidgetRect );
    ui->play->setAttribute( Qt::WA_MacNoClickThrough );
    ui->ban->setAttribute( Qt::WA_MacNoClickThrough );
    ui->love->setAttribute( Qt::WA_MacNoClickThrough );
    ui->skip->setAttribute( Qt::WA_MacNoClickThrough );

    // If the actions are triggered we should do something
    // love is dealt with by the application
    connect( aApp->banAction(), SIGNAL(triggered(bool)), SLOT(onBanClicked()) );
    connect( aApp->playAction(), SIGNAL(triggered(bool)), SLOT(onPlayClicked(bool)) );
    connect( aApp->skipAction(), SIGNAL(triggered(bool)), SLOT(onSkipClicked()) );

    m_playAction = new QAction( tr( "Play" ), aApp );
    connect( m_playAction, SIGNAL(triggered(bool)), aApp->playAction(), SLOT(trigger()) );
    connect( aApp->playAction(), SIGNAL(toggled(bool)), m_playAction, SLOT(setChecked(bool)) );

    // make sure this widget updates if the actions are changed elsewhere
    connect( aApp->loveAction(), SIGNAL(changed()), SLOT(onActionsChanged()) );
    connect( aApp->banAction(), SIGNAL(changed()), SLOT(onActionsChanged()) );
    connect( aApp->playAction(), SIGNAL(changed()), SLOT(onActionsChanged()) );
    connect( aApp->skipAction(), SIGNAL(changed()), SLOT(onActionsChanged()) );

    connect( &RadioService::instance(), SIGNAL(tuningIn(RadioStation)), SLOT(onTuningIn(RadioStation)));
    connect( &RadioService::instance(), SIGNAL(error(int,QVariant)), SLOT(onError(int, QVariant)));

    connect( &ScrobbleService::instance(), SIGNAL(trackStarted(Track,Track)), SLOT(onTrackStarted(Track,Track)) );
    connect( &ScrobbleService::instance(), SIGNAL(stopped()), SLOT(onStopped()));
    connect( &ScrobbleService::instance(), SIGNAL(scrobblingOnChanged(bool)), SLOT(update()));

    onActionsChanged();

    // if our buttons are pressed we should trigger the actions
    connect( ui->love, SIGNAL(clicked()), aApp->loveAction(), SLOT(trigger()));
    connect( ui->ban, SIGNAL(clicked()), aApp->banAction(), SLOT(trigger()));
    connect( ui->play, SIGNAL(clicked()), aApp->playAction(), SLOT(trigger()));
    connect( ui->skip, SIGNAL(clicked()), aApp->skipAction(), SLOT(trigger()));
}
Ejemplo n.º 8
0
 void SpringLayoutUi::onStartStop()
 {
   m_ui.btnStartStop->setEnabled(false);
   if (m_thread == NULL)
   {
     emit runningChanged(true);
     m_thread = new WorkerThread(m_layout, 100 - m_ui.sldSpeed->value(), this);
     m_thread->connect(m_thread, SIGNAL(started()), this, SLOT(onStarted()));
     m_thread->connect(m_thread, SIGNAL(finished()), this, SLOT(onStopped()));
     m_thread->start();
   }
   else
   {
     static_cast<WorkerThread*>(m_thread)->stop();
     m_thread->wait();
     m_thread = NULL;
   }
 }
Ejemplo n.º 9
0
NowPlayingWidget::NowPlayingWidget(QWidget *parent)
    :QWidget(parent)
{
    QVBoxLayout* layout = new QVBoxLayout( this );
    layout->setContentsMargins( 0, 0, 0, 0 );
    layout->setSpacing( 0 );

    layout->addWidget( ui.stack = new QStackedWidget( this ) );

    ui.stack->addWidget( ui.spinner = new QLabel() );
    ui.spinner->setObjectName( "spinner" );
    ui.spinner->setAlignment( Qt::AlignCenter );

    m_movie = new QMovie( ":/loading_meta.gif", "GIF", this );
    m_movie->setCacheMode( QMovie::CacheAll );
    ui.spinner->setMovie ( m_movie );

    ui.metadata = 0;


    connect( &ScrobbleService::instance(), SIGNAL(trackStarted(lastfm::Track,lastfm::Track)), SLOT(onTrackStarted(lastfm::Track,lastfm::Track)) );
    connect( &ScrobbleService::instance(), SIGNAL(stopped()), SLOT(onStopped()) );
}
Ejemplo n.º 10
0
Player::Player(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Player)
{
    std::cout << "Initialize player..." << std::endl;
    ui->setupUi(this);

    //Add MPlayer frame
    mplayer = new MPlayer;
    ui->playerLayout->setMargin(0);
    ui->playerLayout->addWidget(mplayer, 1);
    //enable autohiding toolbar
    mplayer->installEventFilter(this);
    mplayer->setMouseTracking(true);
    mplayer->getLayer()->installEventFilter(this);
    mplayer->getLayer()->setMouseTracking(true);
    ui->toolBar->installEventFilter(this);

    //move window
    ui->titleBar->installEventFilter(this);

    //Add Playlist
    playlist = new Playlist;
    ui->playerLayout->addWidget(playlist);
    playlist->installEventFilter(this);

    //Add Border
    topLeftBorder = new Border(this, Border::LEFT);
    topLeftBorder->setObjectName("topLeftBorder");
    topRightBorder = new Border(this, Border::RIGHT);
    topRightBorder->setObjectName("topRightBorder");
    ui->titleBarLayout->insertWidget(0, topLeftBorder);
    ui->titleBarLayout->addWidget(topRightBorder);

    leftBorder = new Border(this, Border::LEFT);
    leftBorder->setObjectName("leftBorder");
    rightBorder = new Border(this, Border::RIGHT);
    rightBorder->setObjectName("rightBorder");
    bottomBorder = new Border(this, Border::BOTTOM);
    bottomBorder->setObjectName("bottomBorder");
    ui->playerLayout->insertWidget(0, leftBorder);
    ui->playerLayout->addWidget(rightBorder);
    ui->mainLayout->addWidget(bottomBorder);

    ui->pauseButton->hide();
    ui->progressBar->hide();
    playlist->hide();

    //Add Cutterbar
    cutterbar = new CutterBar;
    int insertPos = ui->mainLayout->indexOf(ui->toolBar);
    ui->mainLayout->insertWidget(insertPos, cutterbar);
    cutterbar->hide();
    mplayer->menu->addAction(tr("Cut video"), this, SLOT(showCutterbar()), QKeySequence("C"));

    //Add WebVideo
    webvideo = new WebVideo;
    reslibrary = new ResLibrary;
    webvideo->addTab(reslibrary, tr("Resources"));
    webvideo->setCurrentIndex(0);

    //add downloader
    downloader = new Downloader;
    webvideo->addTab(downloader, tr("Downloader"));

    //add transformer
    transformer = new Transformer;

    //Settings Dialog
    settingsDialog = new SettingsDialog(this);

    //Add menu
    menubar = new QMenuBar;
    menu = menubar->addMenu(tr("Player"));
    menu->addAction(tr("Online video"), webvideo, SLOT(show()));
    menu->addAction(tr("Transform video"), transformer, SLOT(show()));
    menu->addAction(tr("Settings"), this, SLOT(onSetButton()));
    menu->addSeparator();
    menu->addAction(tr("Homepage"), this, SLOT(openHomepage()));
    menu->addAction(tr("About"), this, SLOT(onAboutClicked()));
    ui->mainLayout->insertWidget(0, menubar);

    //Add time show
    timeShow = new QLabel(mplayer);
    timeShow->move(0, 0);
    timeShow->hide();

    //Connect
    connect(ui->playButton, SIGNAL(clicked()), mplayer, SLOT(changeState()));
    connect(ui->pauseButton, SIGNAL(clicked()), mplayer, SLOT(changeState()));
    connect(ui->stopButton, SIGNAL(clicked()), this, SLOT(onStopButton()));
    connect(ui->progressBar, SIGNAL(valueChanged(int)), this, SLOT(onPBarChanged(int)));
    connect(ui->progressBar, SIGNAL(sliderPressed()), this, SLOT(onPBarPressed()));
    connect(ui->progressBar, SIGNAL(sliderReleased()), this, SLOT(onPBarReleased()));
    connect(ui->volumeSlider, SIGNAL(valueChanged(int)), mplayer, SLOT(setVolume(int)));
    connect(ui->volumeSlider, SIGNAL(valueChanged(int)), this, SLOT(onSaveVolume(int)));
    connect(ui->netButton, SIGNAL(clicked()), webvideo, SLOT(show()));
    connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(close()));
    connect(ui->minButton, SIGNAL(clicked()), this, SLOT(showMinimized()));
    connect(ui->maxButton, SIGNAL(clicked()), this, SLOT(setMaxNormal()));
    connect(ui->menuButton, SIGNAL(clicked()), this, SLOT(showMenu()));

    connect(mplayer, SIGNAL(played()), this, SLOT(setIconToPause()));
    connect(mplayer, SIGNAL(paused()), this, SLOT(setIconToPlay()));
    connect(mplayer, SIGNAL(stopped()), this, SLOT(onStopped()));
    connect(mplayer, SIGNAL(timeChanged(int)), this, SLOT(onProgressChanged(int)));
    connect(mplayer, SIGNAL(lengthChanged(int)), this, SLOT(onLengthChanged(int)));
    connect(mplayer, SIGNAL(fullScreen()), this, SLOT(setFullScreen()));
    connect(mplayer, SIGNAL(sizeChanged(QSize&)), this, SLOT(onSizeChanged(QSize&)));

    connect(playlist, SIGNAL(fileSelected(const QString&)), mplayer, SLOT(openFile(const QString&)));
    connect(playlist, SIGNAL(needPause(bool)), this, SLOT(onNeedPause(bool)));

    connect(downloader, SIGNAL(newPlay(const QString&,const QString&)), playlist, SLOT(addFileAndPlay(const QString&,const QString&)));
    connect(downloader, SIGNAL(newFile(const QString&,const QString&)), playlist, SLOT(addFile(const QString&,const QString&)));

    connect(cutterbar, SIGNAL(newFrame(int)), mplayer, SLOT(jumpTo(int)));
    connect(cutterbar, SIGNAL(finished()), cutterbar, SLOT(hide()));
    connect(cutterbar, SIGNAL(finished()), ui->toolBar, SLOT(show()));

    //Set skin
    setSkin(Settings::skinList[Settings::currentSkin]);

    //Set default volume
    ui->volumeSlider->setValue(Settings::volume);

    no_play_next = false;
    is_fullscreen = false;
}
Ejemplo n.º 11
0
void Sensor::stop()
{
    qDebug()<<TAG<<": stop() from thread: "<<QThread::currentThreadId();
    processor_->stop();
    emit onStopped();
}
void
PlayerConnection::handleCommand( PlayerCommand command, Track t )
{
    qDebug() << command;

    try
    {
        switch (command)
        {
            case CommandStart:
                if (t.isNull()) throw FatalError("Can't start a null track");
                m_state = Playing;
                if ( m_stoppedTimer ) m_stoppedTimer->stop();
                if (t == m_track)
                {
                    emit resumed();
                    throw NonFatalError("Already playing this track");
                }
                qSwap(m_track, t);
                m_elapsed = 0;
                emit trackStarted( m_track, t );
                break;
                
            case CommandPause:
                if (m_track.isNull()) throw FatalError("Cannot pause a null track");
                if (m_state == Paused) throw NonFatalError("Already paused");
                m_state = Paused;
                emit paused();
                break;

            case CommandResume:
                if (m_track.isNull()) throw FatalError("Can't resume null track");
                if (m_state == Playing) throw NonFatalError("Already playing");
                m_state = Playing;
                emit resumed();
                break;

            case CommandTerm:
            case CommandInit:
            case CommandStop:
                // don't process the stop straight away because we could be skipping
                // track so wait a second to make sure we don't get a start command
                if ( !m_stoppedTimer )
                {
                    m_stoppedTimer = new QTimer( this );
                    m_stoppedTimer->setSingleShot( true );
                    m_stoppedTimer->setInterval( 1000 );
                    connect( m_stoppedTimer, SIGNAL(timeout()), this, SLOT(onStopped()) );
                }

                m_stoppedTimer->start();
                break;
                
            case CommandBootstrap:
				emit bootstrapReady( id() );
                break;
        }
        
    }
    catch (Error& error)
    {
        qWarning() << error.message();

        if (error.isFatal())
        {
            m_state = Stopped;
            m_track = Track();
            emit stopped();
        }
    }
}