// Plays the media stream. This will play all play lists from start to // finish. OsStatus MpStreamPlaylistPlayer::play(UtlBoolean bBlock /*= TRUE*/) { OsStatus status = OS_FAILED; // If the player is in a failed or unrealized state, abort. if ((mAggregateState == PlayerFailed) || (mAggregateState == PlayerUnrealized)) { OsSysLog::add(FAC_MP, PRI_ERR, "MpStreamPlaylistPlayer::play request failed due to player being in invalid state"); return OS_INVALID_STATE; } if (bBlock) { first(); do { mbAutoAdvance = FALSE; status = playNext(); } while ((status == OS_SUCCESS) && (mCurrentElement < (int)mPlayListDb->entries())); } else { mbAutoAdvance = TRUE; if ((mAggregateState == PlayerPaused) && (mPlayingElement != -1)) { status = playEntry(mPlayingElement, bBlock); } else status = playNext(FALSE); } return status; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); setWindowFlags(Qt::FramelessWindowHint); setAttribute(Qt::WA_TranslucentBackground); ui->horizontalSlider->setRange(0, 0); ui->tableWidget->hide(); ui->tableWidget->hideColumn(2); volume=80; createContextMenu(); createSystemTrayIcon(); playList=new QMediaPlaylist; playList->setPlaybackMode(QMediaPlaylist::Loop); player=new QMediaPlayer; player->setPlaylist(playList); player->setVolume(volume); connect(ui->horizontalSlider, SIGNAL(sliderMoved(int)), this, SLOT(setPosition(int))); connect(ui->tableWidget, SIGNAL(cellClicked(int,int)), this, SLOT(playTo(int, int))); connect(player, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64))); connect(player, SIGNAL(durationChanged(qint64)), this, SLOT(durationChanged(qint64))); connect(playList, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSongList(int))); connect(ui->action_SongList, SIGNAL(triggered()), this, SLOT(showOrHideSongList())); connect(ui->action_Import, SIGNAL(triggered()), this, SLOT(importSongs())); connect(ui->action_Last, SIGNAL(triggered()), this, SLOT(playLast())); connect(ui->action_Play, SIGNAL(triggered()), this, SLOT(playOrPause())); connect(ui->action_Stop, SIGNAL(triggered()), player, SLOT(stop())); connect(ui->action_Next, SIGNAL(triggered()), this, SLOT(playNext())); connect(ui->action_SoundPlus, SIGNAL(triggered()), this, SLOT(plusSound())); connect(ui->action_SoundReduce, SIGNAL(triggered()), this, SLOT(reduceSound())); connect(ui->action_Mode1, SIGNAL(triggered()), this, SLOT(setPlaybackMode1())); connect(ui->action_Mode2, SIGNAL(triggered()), this, SLOT(setPlaybackMode2())); connect(ui->action_Mode3, SIGNAL(triggered()), this, SLOT(setPlaybackMode3())); connect(ui->action_Mode4, SIGNAL(triggered()), this, SLOT(setPlaybackMode4())); connect(ui->action_Support, SIGNAL(triggered()), this, SLOT(support())); connect(ui->action_About, SIGNAL(triggered()), this, SLOT(aboutUs())); connect(ui->action_Quit, SIGNAL(triggered()), this, SLOT(close())); connect(ui->toolButton_Last, SIGNAL(clicked()), this, SLOT(playLast())); connect(ui->toolButton_Play, SIGNAL(clicked()), this, SLOT(playOrPause())); connect(ui->toolButton_Stop, SIGNAL(clicked()), player, SLOT(stop())); connect(ui->toolButton_Next, SIGNAL(clicked()), this, SLOT(playNext())); }
int ai::play(const playfield &pField) { ext_playfield privateField(pField); // copy playfield in my own rep // either 1 (player1) or 2 (player2) playerRole = determinePlayerRole(privateField); if (playerRole == 2) { // determine next move return playNext(1, privateField); } // i am player 1 -> i play first return playNext(2, privateField); }
void Player::trackFinished() { if (!_isStopped) { playNext(); } }
//------------------------------------------------------------------------------------- ///implements onSoundStopped for cyclic play void Sound::OnSoundStopped (irrklang::ISound* isound, irrklang::E_STOP_EVENT_CAUSE reason, void* userData){ if(reason==irrklang::ESEC_SOUND_FINISHED_PLAYING||reason==irrklang::ESEC_SOUND_STOPPED_BY_USER){ playNext(); } }
void MDArpeggiatorClass::on16Callback() { if (triggerRecording && (MidiClock.div16th_counter % 16) == 0) { triggerRecording = false; recording = true; recordStart = MidiClock.div16th_counter; for (int i = 0; i < 64; i++) { recordPitches[i] = 128; } } if (recording || endRecording) { int pos = MidiClock.div16th_counter - recordStart; if (pos >= (recordLength * 3)) { endRecording = false; } else if (pos >= (recordLength * 2)) { recording = false; endRecording = true; return; } } if (!triggerRecording) { playNext(recording); } }
void PlayableItemWidget::contextMenuEvent( QContextMenuEvent* event ) { QMenu* contextMenu = new QMenu( this ); contextMenu->addAction( tr( "Play %1" ).arg( m_rs.title() ), this, SLOT(play())); if ( RadioService::instance().state() == Playing ) contextMenu->addAction( tr( "Cue %1" ).arg( m_rs.title() ), this, SLOT(playNext())); if ( m_rs.url().startsWith( "lastfm://user/" ) && ( m_rs.url().endsWith( "/library" ) || m_rs.url().endsWith( "/personal" ) ) && m_rs.url() != RadioStation::library( User() ).url() ) { int endPos = m_rs.url().indexOf( "/", 14 ); if ( endPos == -1 ) endPos = m_rs.url().length(); // if it's a user station that isn't yours we should // let them start a multi-station with yours contextMenu->addSeparator(); contextMenu->addAction( tr( "Play %1 and %2 Library Radio" ).arg( m_rs.url().mid( 14, endPos - 14 ), User().name() ), this, SLOT(playMulti())); if ( RadioService::instance().state() == Playing ) contextMenu->addAction( tr( "Cue %1 and %2 Library Radio" ).arg( m_rs.url().mid( 14, endPos - 14 ), User().name() ), this, SLOT(playMultiNext())); } if ( contextMenu->actions().count() ) contextMenu->exec( event->globalPos() ); }
void Player::playFinished() { mediaObject->stop(); setState(Player::FINISHED); autoNext = true; playNext(); }
void RoboyMediaPlayerInteraction::newPlaylist(Roboy::RoboyVideoPlaylist videos) { playlist_mutex.lock(); playlists.push(videos); playlist_mutex.unlock(); if(playlists.size() == 1) playNext(); }
void WebserviceTTSProvider::initializeOutput() { if (player) { player->stop(); player->deleteLater(); } player = new WavPlayerClient(); connect(player, SIGNAL(finished()), this, SLOT(playNext())); }
void MainBottomWidget::initConnect() { connect(m_playButton, SIGNAL(clicked()), this, SLOT(on_playButton_clicked())); connect(m_playFrontButton, SIGNAL(clicked()), this, SIGNAL(playFront())); connect(m_playNextButton, SIGNAL(clicked()), this, SIGNAL(playNext())); // 进度条 connect(m_voiceWidget, SIGNAL(changeTo(qreal)), this, SLOT(voiceChanged(qreal))); connect(m_postionWidget, SIGNAL(changeTo(qreal)), this, SLOT(postionChanged(qreal))); }
unsigned int arlCore::Player::initPlayer( const std::string &fileName ) { m_playerFullName = fileName; m_afterHeader = 0; if(!readHeader(fileName)) return 0; m_afterHeader = m_playerHandle.tellg(); unsigned int n = playNext(); m_isReady = n>0; m_eof = !m_isReady; return n; }
void Shadows::update(){ // shadow bluring // blur.begin(); ofPushStyle(); ofClear(255,255); if ( countDown == 0){ // Play the shadows animation one by one from the last up to the first one // Ever time a new shadow it´s made, the cicle start´s from the beginning. // ofFill(); if (currentShadow != NULL){ if (currentShadow->bActive){ if ( currentShadow->draw() ){ if (bNew){ playLast(); bNew = false; } else { playNext(); } } } } } else { int clamp = nLastShadows; if (clamp > 5){ clamp = 5; } for( map<int,AnimatedShadow*>::reverse_iterator rit = hands.rbegin(); rit != hands.rend(); rit++ ){ if ((clamp > 0) || rit->second->getCurrentFrame() != 0){ if ( rit->second->bActive ) { rit->second->draw(); clamp--; } } } countDown--; if ((countDown == 0) && (nLastShadows > 0) ){ countDown = 100; nLastShadows--; } } ofPopStyle(); blur.end(); blur.update(); // Animate the text // text.update(); textAnimation.update(text); }
void AudioPlayer::next() { if (!queue_.isEmpty()) { auto enqueued = queue_.popTrack(); if (enqueued.second.isValid()) { playingModel_ = enqueued.first; play(playingModel_, enqueued.second); return; } } playNext(+1); }
void rotateFinishCallback() { if (rotateMethod == ROTATE_NONE) return; cube.DoMethod(rotateMethod); rotateAngle = 0.0; rotateMethod = ROTATE_NONE; if (playing) { playNext(); } }
void PlaybackWaitItem::play() { if( m_isPlaying ){ return; } else { m_isPlaying = true; if ( !( m_start.isValid() ) ){ m_start = QDateTime::currentDateTime(); Q_ASSERT( m_start.isValid() ); } else { m_start = m_start.addMSecs( m_pause.msecsTo( QDateTime::currentDateTime() ) ); } playNext(); } }
void RoboyMediaPlayerInteraction::runPlayer() { fclose(stderr); // Because mplayer outputs stuff that clutters the console FILE *fh = popen(mplayerBin.c_str(), "r"); size_t bufSize = 511; char *buf = (char*) malloc(bufSize+1); while(1) { boost::this_thread::interruption_point(); getline(&buf, &bufSize, fh); // std::cout << buf; FIXME: Logger: debug if(!std::strncmp(buf, "EOF code: 1", 11)) playNext(); } }
void PlaybackWaitItem::playNext() { if( !m_start.isValid() ){ return; } double const progress = m_start.msecsTo( QDateTime::currentDateTime() ) / 1000.0; Q_ASSERT( progress >= 0.0 ); double const t = progress / m_wait->duration(); if( t <= 1 ){ if( m_isPlaying ){ emit progressChanged( progress ); QTimer::singleShot( 20, this, SLOT(playNext()) ); } } else { stop(); emit finished(); } }
void handleSignals() { if (wasSigChld) { wasSigChld = 0; if (!isPlaying()) return; /*synthesizer group processing*/ if (pid != (pid_t)0) { pid_t pp = 0; pid_t p = waitpid(pid, NULL, WNOHANG); while(1) { pp = waitpid(-1 * pid, NULL, WNOHANG); if (pp <= (pid_t)0)/*All zombies are collected, but there can be live processes*/ break; /*yes, we have picked up real zombie and must try new waitpid(), there can be more*/ } /*while()*/ if (p != (pid_t)0 && pp != (pid_t)0) pid = 0; } /*synthesizer group processing*/ /*player group processing*/ if (playerPid != (pid_t)0) { pid_t pp = 0; pid_t p = waitpid(playerPid, NULL, WNOHANG); while(1) { pp = waitpid(-1 * playerPid, NULL, WNOHANG); if (pp <= (pid_t)0)/*All zombies are collected, but there can be live processes*/ break; /*yes, we have picked up real zombie and must try new waitpid(), there can be more*/ } /*while()*/ if (p != (pid_t)0 && pp != (pid_t)0) playerPid = 0; } /*player group processing*/ if (isPlaying()) return; playNext(); } }
// Handles processing for the stopped state void MpStreamPlaylistPlayer::handleStoppedState(PlayerState oldState, PlayerState newState) { if ( (mbAutoAdvance) && (mCurrentElement < (int)mPlayListDb->entries()) && (newState != PlayerAborted)) { playNext(FALSE); } else if (newState == PlayerAborted) { if (mAggregateState != PlayerAborted) { #ifdef MP_STREAM_DEBUG /* [ */ osPrintf("MpStreamPlaylistPlayer::handleStoppedState(%p): Changed from %s to PlayerAborted.\n", this, getEventString(mAggregateState)); #endif /* ] */ mAggregateState = PlayerAborted; fireEvent(PlayerAborted); // Wake up anyone waiting on play completion. mWaitEvent.signal(0); } } else { if (mCurrentElement >= (int)mPlayListDb->entries()) { mbAutoAdvance = FALSE; if (mAggregateState != PlayerStopped) { #ifdef MP_STREAM_DEBUG /* [ */ osPrintf("MpStreamPlaylistPlayer::handleStoppedState(%p): Changed from %s to PlayerStopped.\n", this, getEventString(mAggregateState)); #endif /* ] */ mAggregateState = PlayerStopped; fireEvent(PlayerStopped); // Wake up anyone waiting on play completion. mWaitEvent.signal(0); } } } }
bool QSpotifySession::event(QEvent *e) { if (e->type() == NotifyMainThreadEventType) { qDebug() << "Process spotify event"; processSpotifyEvents(); e->accept(); return true; } else if (e->type() == QEvent::Timer) { qDebug() << "Timer, start spotify events"; QTimerEvent *te = static_cast<QTimerEvent *>(e); if (te->timerId() == m_timerID) { processSpotifyEvents(); e->accept(); return true; } } else if (e->type() == ConnectionErrorEventType) { qDebug() << "Connection error"; QSpotifyConnectionErrorEvent *ev = static_cast<QSpotifyConnectionErrorEvent *>(e); setConnectionError(ConnectionError(ev->error()), QString::fromUtf8(sp_error_message(ev->error()))); e->accept(); return true; } else if (e->type() == MetaDataEventType) { qDebug() << "Meta data"; emit metadataUpdated(); e->accept(); return true; } else if (e->type() == EndOfTrackEventType) { qDebug() << "End track"; m_trackChangedAutomatically = true; playNext(); e->accept(); return true; } else if (e->type() == StopEventType) { qDebug() << "Stop"; stop(); e->accept(); return true; } else if (e->type() == TrackProgressEventType) { qDebug() << "Track progress"; if(!m_isPlaying) { e->accept(); return true; } // Track progressed QSpotifyTrackProgressEvent *ev = static_cast<QSpotifyTrackProgressEvent *>(e); int currentTrackPositionDelta = ev->delta(); if (m_previousTrackRemaining > 0) { // We're still playing the previous back from our buffer int fromPreviousTrack = qMin(currentTrackPositionDelta, m_previousTrackRemaining); currentTrackPositionDelta -= fromPreviousTrack; m_previousTrackRemaining -= fromPreviousTrack; } m_currentTrackPosition += currentTrackPositionDelta; m_currentTrackPlayedDuration += currentTrackPositionDelta; emit currentTrackPositionChanged(); e->accept(); return true; } else if (e->type() == SendImageRequestEventType) { qDebug() << "Send image request"; QSpotifyRequestImageEvent *ev = static_cast<QSpotifyRequestImageEvent *>(e); sendImageRequest(ev->imageId()); e->accept(); return true; } else if (e->type() == ReceiveImageRequestEventType) { qDebug() << "Receive image request"; QSpotifyReceiveImageEvent *ev = static_cast<QSpotifyReceiveImageEvent *>(e); receiveImageResponse(ev->image()); e->accept(); return true; } else if (e->type() == PlayTokenLostEventType) { qDebug() << "Play token lost"; emit playTokenLost(); pause(); e->accept(); return true; } else if (e->type() == LoggedInEventType) { qDebug() << "Logged in 1"; onLoggedIn(); e->accept(); return true; } else if (e->type() == LoggedOutEventType) { qDebug() << "Logged out"; onLoggedOut(); e->accept(); return true; } else if (e->type() == OfflineErrorEventType) { qDebug() << "Offline error"; QSpotifyOfflineErrorEvent *ev = static_cast<QSpotifyOfflineErrorEvent *>(e); m_offlineErrorMessage = QString::fromUtf8(sp_error_message(ev->error())); emit offlineErrorMessageChanged(); e->accept(); return true; } else if (e->type() == ScrobbleLoginErrorEventType) { qDebug() << "Scrobble login error"; m_lfmLoggedIn = false; emit lfmLoggedInChanged(); emit lfmLoginError(); e->accept(); return true; } else if (e->type() == ConnectionStateUpdateEventType) { qDebug() << "Connectionstate update event"; setConnectionStatus(ConnectionStatus(sp_session_connectionstate(m_sp_session))); if (m_offlineMode && m_connectionStatus == LoggedIn) { setConnectionRules(m_connectionRules | AllowNetwork); setConnectionRules(m_connectionRules & ~AllowNetwork); } e->accept(); return true; } return QObject::event(e); }
Player::Player(QWidget *parent): QMainWindow(parent), _ui(new Ui::Player), _player(new Phonon::MediaObject(this)), _audioOutput(new Phonon::AudioOutput(Phonon::MusicCategory, this)), _trayIcon(new QSystemTrayIcon(this)), _isStopped(false), _isPaused(false), _artistToPlaylistAction(new QAction(tr("Add to playlist"), this)), _artistsMenu(new QMenu(this)), _albumToPlaylistAction(new QAction(tr("Add to playlist"), this)), _albumsMenu(new QMenu(this)), _trackToPlaylistAction(new QAction(tr("Add to playlist"), this)), _tracksMenu(new QMenu(this)), _removeTrackAction(new QAction(tr("Remove track"), this)), _playlistMenu(new QMenu(this)), _playAction(new QAction(tr("Play"), this)), _pauseAction(new QAction(tr("Pause"), this)), _playNextAction(new QAction(tr("Play next"), this)), _playPrevAction(new QAction(tr("Play previous"), this)), _stopAction(new QAction(tr("Stop"), this)), _trayMenu(new QMenu(this)), _lastFMDialog(new LastFMAuthDialog(this)) { _ui->setupUi(this); this->setWindowIcon(QIcon(":/icon.png")); this->setWindowTitle(qApp->applicationName()); _ui->pauseButton->setHidden(true); fixHeader(_ui->tracks->horizontalHeader()); fixHeader(_ui->playlist->horizontalHeader()); _ui->tracks->verticalHeader()->setDefaultSectionSize(_ui->artists->sizeHintForRow(0) + 4); _ui->playlist->verticalHeader()->setDefaultSectionSize(_ui->artists->sizeHintForRow(0) + 4); _ui->previousButton->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaSkipBackward)); _ui->playButton->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaPlay)); _ui->pauseButton->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaPause)); _ui->stopButton->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaStop)); _ui->nextButton->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaSkipForward)); _playPrevAction->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaSkipBackward)); _playAction->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaPlay)); _pauseAction->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaPause)); _pauseAction->setVisible(false); _stopAction->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaStop)); _playNextAction->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaSkipForward)); _ui->actionQuit->setIcon(qApp->style()->standardIcon(QStyle::SP_DialogCloseButton)); _trayMenu->addAction(_playAction); _trayMenu->addAction(_pauseAction); _trayMenu->addAction(_playPrevAction); _trayMenu->addAction(_playNextAction); _trayMenu->addAction(_stopAction); _trayMenu->addAction(_ui->actionQuit); _trayIcon->setContextMenu(_trayMenu); _trayIcon->setIcon(QIcon(":/icon.png")); _trayIcon->show(); Phonon::createPath(_player, _audioOutput); _ui->seekSlider->setMediaObject(_player); _ui->volumeSlider->setAudioOutput(_audioOutput); _artistsMenu->addAction(_artistToPlaylistAction); _albumsMenu->addAction(_albumToPlaylistAction); _tracksMenu->addAction(_trackToPlaylistAction); _playlistMenu->addAction(_removeTrackAction); connect(_ui->actionQuit, SIGNAL(triggered()), qApp, SLOT(quit())); connect(_ui->actionAdd_directory, SIGNAL(triggered()), this, SLOT(addDirToLibrary())); connect(_ui->actionAdd_files, SIGNAL(triggered()), this, SLOT(addFilesToLibrary())); connect(_ui->actionClear_playlist, SIGNAL(triggered()), this, SLOT(clearPlaylist())); connect(_ui->actionLoad_playlist, SIGNAL(triggered()), this, SLOT(loadPlaylist())); connect(_ui->actionSave_playlist, SIGNAL(triggered()), this, SLOT(savePlaylist())); connect(_ui->nextButton, SIGNAL(clicked()), this, SLOT(playNext())); connect(_ui->playButton, SIGNAL(clicked()), this, SLOT(play())); connect(_ui->tracks, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(playSelected())); connect(_ui->playlist, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(playSelected())); connect(_ui->stopButton, SIGNAL(clicked()), this, SLOT(stop())); connect(_ui->pauseButton, SIGNAL(clicked()), this, SLOT(pause())); connect(_ui->stopButton, SIGNAL(clicked()), _player, SLOT(stop())); connect(_ui->previousButton, SIGNAL(clicked()), this, SLOT(playPrevious())); connect(_playAction, SIGNAL(triggered()), this, SLOT(play())); connect(_pauseAction, SIGNAL(triggered()), _player, SLOT(pause())); connect(_stopAction, SIGNAL(triggered()), _player, SLOT(stop())); connect(_playNextAction, SIGNAL(triggered()), this, SLOT(playNext())); connect(_playPrevAction, SIGNAL(triggered()), this, SLOT(playPrevious())); connect(_ui->artists, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showArtistsContextMenu(const QPoint &))); connect(_ui->albums, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showAlbumsContextMenu(const QPoint &))); connect(_ui->tracks, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showTracksContextMenu(const QPoint &))); connect(_ui->playlist, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showPlaylistContextMenu(const QPoint &))); connect(DataBase::instance(), SIGNAL(albumsUpdated()), this, SLOT(updateAlbums())); connect(DataBase::instance(), SIGNAL(artistsUpdated()), this, SLOT(updateArtists())); connect(DataBase::instance(), SIGNAL(tracksUpdated()), this, SLOT(updateTracks())); connect(_ui->artists, SIGNAL(currentRowChanged(int)), this, SLOT(updateAlbums())); connect(_ui->albums, SIGNAL(currentRowChanged(int)), this, SLOT(updateTracks())); connect(_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); connect(_player, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(stateChanged(Phonon::State,Phonon::State))); connect(_player, SIGNAL(tick(qint64)), this, SLOT(tick(qint64))); connect(_player, SIGNAL(totalTimeChanged(qint64)), this, SLOT(totalTimeChanged(qint64))); connect(_player, SIGNAL(finished()), this, SLOT(trackFinished())); connect(_ui->actionSettings, SIGNAL(triggered()), _lastFMDialog, SLOT(show())); connect(_ui->actionScrobbling, SIGNAL(toggled(bool)), this, SLOT(scrobblingToggled(bool))); connect(Settings::instance(), SIGNAL(scrobblingChanged(bool)), _ui->actionScrobbling, SLOT(setChecked(bool))); _allArtists = _ui->artists->item(0); _allArtists->setText(ALL); _allAlbums = _ui->albums->item(0); _allAlbums->setText(ALL); loadPlaylist(RECENTPLAYLIST); _ui->actionScrobbling->setChecked(Settings::instance()->isScrobblingEnabled()); _ui->actionSettings->setEnabled(Settings::instance()->isScrobblingEnabled()); scrobblingToggled(Settings::instance()->isScrobblingEnabled()); }
void AudioPlayer::play() { playNext(0); }
void MusicPlayer::update() { // Continues playing more music when the current music ends if (!noMusic && music.getStatus() != sf::Music::Playing) playNext(); }
MyMainWindow::MyMainWindow(EventManager *event_manager, MediaPlayer *p) : MainWindow(0, Rect(0, 0, GRSYS_WIDTH, GRSYS_HEIGHT), event_manager), m_headText(event_manager, Rect(rect().x(), rect().y(), rect().w(), 24)), m_playPos(Rect(), this), m_lastTouchedButton(0), m_functionalTab(Rect(0, rect().h()-48, rect().w(), 48), this, TabBox::Horizontal), m_stopButton(Rect(), this, ""), m_prevButton(Rect(), this, ""), m_playButton(Rect(), this, ""), m_nextButton(Rect(), this, ""), m_mediaList(Rect(4, 0, rect().w()-8, 0), this), m_musicImage(resource_manager->image("music")), setup_handle(-1), m_player(p), m_currentPlayedItem(0) { setup_handle = SetUP_GetHandle(); m_playImg = &resource_manager->image("play"); m_stopImg = &resource_manager->image("stop"); m_pauseImg = &resource_manager->image("pause"); m_prevImg = &resource_manager->image("prev"); m_nextImg = &resource_manager->image("next"); m_headText.setText( path2name(m_player->file()) ); m_headText.start(200); m_headText.setTextSize(18); m_headText.setTextAttrs(FT_TEXT_H_CENTER); m_playPos.setSize( Rect(9, rect().h()-78, rect().w()-18, 16) ); m_playPos.show(); m_playPos.positionSelected().connect( [this](int pos) { //printf("Percent: %d\n", pos); unsigned int ms = m_player->length()*pos / 100; m_player->seek(ms); }); //m_timer.start(1000); m_timer.timerEventSignal().connect( [this](Timer *) { eventManager()->updateAfterEvent(); }); m_functionalTab.show(); m_functionalTab.addTab("List"); m_functionalTab.addTab("Play"); m_functionalTab.addTab("Info"); m_functionalTab.addTab("Exit"); m_functionalTab.setFocusTab(1); m_functionalTab.onTabChanged().connect( this, &MyMainWindow::tabBoxChanged, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); setupMediaButtons(); ListMenuStyle menu_style = m_mediaList.style(); menu_style.setShadow( Brush() ); menu_style.setBackground( Brush() ); m_mediaList.setStyle(menu_style); Rect rc = m_mediaList.rect(); rc.setY(m_headText.size().h() + m_prevButton.rect().h()+10); rc.setH( rect().h() - (m_mediaList.rect().y() + (rect().h() - m_playPos.rect().y()) + 90 )); m_mediaList.setSize(rc); m_mediaList.resizeEvent(); scanFolder(); m_player->endAction().connect( [this](MediaPlayer *){ playNext(); }); }
void MyMainWindow::setupMediaButtons() { auto paintBackground = [](const Rect &r, GLColor begin, GLColor ) { /*GLGradient g; glAllocateGradient(&g, 2); g.colors[0].color = begin; //0xFF2a0708; g.colors[0].pixels = r.h(); g.colors[1].color = end; //0xFF8f0f0f; glDrawGradient(r.x(), r.y(), r.w(), r.h(), 2, &g); glDestroyGradient(&g);*/ glSetPen(begin); glDrawFilledRectange(r.x(), r.y(), r.x2(), r.y2()); }; ButtonStyle bstyle; //bstyle.setBorder(Brush(0xFFFFFFFF, false)); //bstyle.setPressedBorder(Brush(0xFFFFFFFF, false)); bstyle.setBorder(Brush()); bstyle.setPressedBorder(Brush()); bstyle.setRoundedRect(false); bstyle.setShadowAfterBackground(true); bstyle.setFontFlags( bstyle.fontFlags() | FT_TEXT_NOCALC_HCENTER ); bstyle.setBackground( Brush( [&paintBackground](Brush &, const Rect &r) { paintBackground(r, 0xFF000000, 0xFF000000); } )); bstyle.setPressedBackground( Brush( [&paintBackground](Brush &, const Rect &r) { paintBackground(r, 0xFF000000, 0xFF000000); } )); int width = (rect().w()) / 4; int xpos = 0; m_stopButton.setSize(Rect(xpos, m_headText.size().y2()+2, width, 40)); m_stopButton.setStyle(bstyle); m_stopButton.setIcon(m_stopImg); xpos += m_stopButton.rect().w(); m_stopButton.releasedSignal().connect( [this](Button *) { m_player->stop(); m_playButton.setIcon(m_playImg); }); m_prevButton.setSize(Rect(xpos, m_headText.size().y2()+2, width, 40)); m_prevButton.setStyle(bstyle); m_prevButton.setIcon(m_prevImg); xpos += m_prevButton.rect().w(); m_prevButton.releasedSignal().connect( [this](Button *) { playPrev(); }); m_playButton.setSize(Rect(xpos, m_headText.size().y2()+2, width, 40)); m_playButton.setStyle(bstyle); m_playButton.setIcon( m_player->isPlaying()? m_pauseImg : m_playImg ); xpos += m_playButton.rect().w(); m_playButton.releasedSignal().connect( [this](Button *b) { if(m_player->isPlaying()) { if(!m_player->isPause()) { m_player->pause(); b->setIcon(m_playImg); } else { m_player->resume(); b->setIcon(m_pauseImg); } } else { m_player->play(m_playFile); b->setIcon(m_pauseImg); } b->eventManager()->updateAfterEvent(); } ); m_nextButton.setSize(Rect(xpos, m_headText.size().y2()+2, width, 40)); m_nextButton.setStyle(bstyle); m_nextButton.setIcon(m_nextImg); m_nextButton.releasedSignal().connect( [this](Button *) { playNext(); }); m_prevButton.show(); m_stopButton.show(); m_playButton.show(); m_nextButton.show(); }
void AudioPlayer::prev() { playNext(-1); }
void TrackWidget::contextMenuEvent( QContextMenuEvent* event ) { QMenu* contextMenu = new QMenu( this ); if ( ! m_nowPlaying ) { contextMenu->addAction( tr( "Delete this scrobble from your profile" ), this, SLOT(onRemoveClicked())); contextMenu->addSeparator(); } contextMenu->addAction( tr( "Play %1 Radio" ).arg( m_track.artist().name() ), this, SLOT(play())); if ( RadioService::instance().state() == Playing ) contextMenu->addAction( tr( "Cue %1 Radio" ).arg( m_track.artist().name() ), this, SLOT(playNext())); if ( contextMenu->actions().count() ) contextMenu->exec( event->globalPos() ); }
VideoPlayer::VideoPlayer(QString programPath, QWidget *parent) : QWidget(parent) ,programDir(programPath) ,WIDTH(600) ,HEIGHT(380) ,videoNameWidth(300) ,videoListWidth(200) ,hideButtonsTime(2000) ,forwardStep(5) ,retreatStep(5) ,volumnChangeStep(5) ,hideCursor(false) ,keepAwakeTimes(0) { //设置窗口无边框 this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint); this->installEventFilter(this); //初始化窗口位置、大小 QDesktopWidget desktop; setGeometry((desktop.width()-WIDTH)/2, (desktop.height()-HEIGHT)/2, WIDTH, HEIGHT); setObjectName("videoPlayer"); //背景label lab_background = new QLabel(this); lab_background->setGeometry(0, 0, WIDTH, HEIGHT); lab_background->setObjectName("lab_background"); // videoList = new VideoList(0, 25, videoListWidth, this->height()-50, false, this); // videoList->show(); //设置鼠标跟踪,响应鼠标移动事件 this->setMouseTracking(true); lab_background->setMouseTracking(true); // videoWidget = new VideoWidget; videoWidget->hide(); videoWidget->installEventFilter(this); videoWidget->setMouseTracking(true); //保持视频屏幕常亮 helpKeepAwake = new HelpKeepAwake; //布局 layout_top = new QGridLayout; layout_top->addWidget(lab_background, 0, 0, 1, 1); layout_top->addWidget(videoWidget, 0, 0, 1, 1); layout_top->setSpacing(0); layout_top->setMargin(0); this->setLayout(layout_top); // videoContral = new VideoContral(this); videoContral->setGeometry(this->x(), this->y(), this->width(), this->height()); tbn_openVideoFile = new QToolButton(this); tbn_openVideoFile->setText("放入视频"); tbn_openVideoFile->setGeometry((this->width()-126-32)/2+35, (this->height()-41)/2+95, 80, 30); tbn_openVideoFile->setObjectName("tbn_openVideoFile"); //初始化多媒体播放器 player = new QMediaPlayer(this); QMediaPlaylist *playlist = new QMediaPlaylist; QMediaPlaylist *playlistHistory = new QMediaPlaylist; playlist_list.append(playlistHistory); playlist_list.append(playlist); player->setVideoOutput(videoWidget); player->setPlaylist(playlist); player->setVolume(60); connect(tbn_openVideoFile,SIGNAL(clicked()), this, SLOT(openVideoFile())); connect(player, SIGNAL(metaDataChanged()), this, SLOT(metaDataChanged())); /* connect(this, SIGNAL(moveWindow(QPoint)), videoList, SLOT(toMoveWindow(QPoint)));*/ //设置样式表 setStyleSheet( "#videoPlayer{" // "border-radius: 3px;" "}" "#lab_background{" // "border-radius: 3px;" "border-image: url(:/Images/videoPlayerBg.png);" "}" "#tbn_openVideoFile{" "background: rgba(0, 0, 0, 30);" "color: rgba(200, 255, 255, 255);" "}" ); //创建定时器(1.5秒无鼠标动作按钮自动隐藏) timerHideWidgets = new QTimer(this); timerHideWidgets->start(hideButtonsTime); connect(timerHideWidgets, SIGNAL(timeout()), this, SLOT(hideWidgets_timeout())); //操作控制 connect(videoWidget, SIGNAL(clicked()), this, SLOT(videoPlayPause())); connect(videoWidget, SIGNAL(switchFullScreen()), this, SLOT(switchFullScreen())); // connect(videoWidget, SIGNAL(goForward()), this, SLOT(videoGoForward())); // connect(videoWidget, SIGNAL(retreat()), this, SLOT(videoRetreat())); connect(videoWidget, SIGNAL(playJump(int)), this, SLOT(videoPlayJump(int))); connect(videoWidget, SIGNAL(volumnAdd()), this, SLOT(volumnAdd())); connect(videoWidget, SIGNAL(volumnReduce()), this, SLOT(volumnReduce())); connect(videoContral, SIGNAL(isHideWidget(bool)), this, SLOT(isHideWidget(bool))); connect(videoContral, SIGNAL(playerStop()), player, SLOT(stop())); connect(videoContral, SIGNAL(playPause()), this, SLOT(videoPlayPause())); connect(videoContral, SIGNAL(playNext()), player->playlist(), SLOT(next())); connect(videoContral, SIGNAL(currentMediaEnd()), this, SLOT(currentMediaEnd())); // connect(videoContral, SIGNAL(goForward()), this, SLOT(videoGoForward())); // connect(videoContral, SIGNAL(retreat()), this, SLOT(videoRetreat())); connect(videoContral, SIGNAL(playJump(int)), this, SLOT(videoPlayJump(int))); connect(videoContral, SIGNAL(switchFullScreen()), this, SLOT(switchFullScreen())); connect(player, SIGNAL(durationChanged(qint64)), videoContral, SLOT(durationChanged(qint64))); connect(player, SIGNAL(durationChanged(qint64)), this, SLOT(setVideoTitle())); connect(player, SIGNAL(positionChanged(qint64)), videoContral, SLOT(positionChanged(qint64))); connect(player, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(playStateChanged(QMediaPlayer::State))); // connect(videoContral, SIGNAL(itemDoubleClicked(int, int)), this, SLOT(itemDoubleClicked(int, int))); // videoWidget->setFocus(); timerKeepAwake = new QTimer(this); connect(timerKeepAwake, SIGNAL(timeout()), this, SLOT(timeoutKeepAwake())); }
void CPlayerList::start() { QSettings settings(QCoreApplication::applicationDirPath () + "/config.ini", QSettings::IniFormat); scene = new QGraphicsScene(desk.screenGeometry(), this); scene->setBackgroundBrush(Qt::black); if( settings.value("displayDefaultImage",true).toBool() ) { CImage *image = new CImage(QPixmap(":/images/horux.png")); image->setDuration(5000); mediaList << image; connect(image, SIGNAL(finished()), this, SLOT(playNext())); } splash = new SplashItem(); splash->setZValue(5); splash->setPos(100, scene->sceneRect().top()); scene->addItem(splash); myview = new QGraphicsView(scene); myview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); myview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); myview->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); myview->setFrameShadow(QFrame::Plain); myview->setFrameShape(QFrame::NoFrame); myview->showFullScreen(); myview->setCursor( QCursor( Qt::BlankCursor ) ); QString mediaPath = settings.value("media_path","").toString(); QSqlQuery query("SELECT * FROM hr_horux_media_media WHERE published=1 AND id_device=" + deviceId + " ORDER by `order`"); while(query.next()) { QString type = query.value(2).toString(); QString path = mediaPath + query.value(3).toString(); int time = query.value(4).toInt(); QFile file(path); if(file.exists()) { if(type == "IMAGE") { CImage *image = new CImage(QPixmap(path)); image->setDuration(time * 1000); mediaList << image; connect(image, SIGNAL(finished()), this, SLOT(playNext())); } if(type == "MOVIE") { VideoWidget *video = new VideoWidget(); video->setDuration(time * 1000); video->setMedia(path); mediaList << video; connect(video, SIGNAL(finished()), this, SLOT(playNext())); } } } if(mediaList.count() == 0) { CImage *image = new CImage(QPixmap(":/images/horux.png")); image->setDuration(5000); mediaList << image; connect(image, SIGNAL(finished()), this, SLOT(playNext())); } group = new QtStateGroup(scene); createTransition(); stateList.at(0)->activate(); isStart = true; if(mediaList.size() > 0) { index = 0; playNext(); } }