void MediaObject::play() { K_D(MediaObject); if (d->backendObject() && isPlayable(d->mediaSource.type())) { INTERFACE_CALL(play()); } }
void MediaObject::seek(qint64 time) { K_D(MediaObject); if (d->backendObject() && isPlayable(d->mediaSource.type())) { INTERFACE_CALL(seek(time)); } }
void MediaObject::enqueue(const MediaSource &source) { K_D(MediaObject); if (!isPlayable(d->mediaSource.type())) { // the current source is nothing valid so this source needs to become the current one setCurrentSource(source); } else { d->sourceQueue << source; } }
MediaObject *createPlayer(Phonon::Category category, const MediaSource &source) { MediaObject *mo = new MediaObject; AudioOutput *ao = new AudioOutput(category, mo); createPath(mo, ao); if (isPlayable(source.type())) { mo->setCurrentSource(source); } return mo; }
// return true if there is at least one pair of tiles // that can be swapped so that a tripel tile can be // eliminated const bool GameField::isPlayable(void) const { bool playable = false; // we go through each column and row and swap single elements for ( unsigned int i = 0; i < FIELD_WIDTH-1; i++ ) { for ( unsigned int j = 0; j < FIELD_HEIGHT-1; j++ ) { // set positions for swapping FieldPos pos1(i,j); FieldPos pos2(i,j+1); if (isPlayable(pos1,pos2)) { playable = true; // leave for-loop break; } // set positions for swapping pos1.set(i,j); pos2.set(i+1,j); if ( isPlayable(pos1,pos2) ) { playable = true; // leave for-loop break; } } if ( playable ) { // leave for-loop break; } } return playable; }
// creates a new game field with random tiles // until the game field is playable void GameField::create(void) { do { // create field with random tiles createRandom(); // cascade tiles until not more than two eqal tiles are next to each other cascade(); } while ( !isPlayable() ); }
// tries to swap two tiles // return true if playable afterwards const bool GameField::swapTiles(const FieldPos& pos1, const FieldPos& pos2) { // check if playable afterwards bool playable = isPlayable(pos1, pos2); if (playable) { // swap tiles getTile(pos1).swap( getTile(pos2) ); } return playable; }
void WorldGen::generateChunks(const util::SlicedTask::Yield& yield){ PROFILE(); while (!chunkGens.empty() && !quit){ for (auto it= chunkGens.begin(); it != chunkGens.end(); ++it) { if (it->isPlayable()) continue; // Playable chunks are generated elswehere it->generate(worldMgr->getTime(), yield); if (quit) break; } yield(); } }
void retrieveDir(char * path) { DIR *pdir; if(path) { chdir(path); getcwd(cwd, FILENAME_MAX); /* Free old directory BEFORE we set numEnt to 0 */ freeDir(); numEnt = 0; scrollY = 0; drgY[1] = drgY[0] = 0; struct dirent *pent; pdir=opendir(cwd); if (pdir) { chdir(cwd); while ((pent=readdir(pdir))!=NULL) { if(strcmp(".", pent->d_name) == 0) continue; if(pent->d_type==DT_REG) { if(isPlayable(pent->d_name)<0) continue; } void * temp = realloc(list, sizeof(char**)*(numEnt+1)); if(temp) { list = temp; int toAlloc = ((strlen(pent->d_name) + sizeof(char)*2)); list[numEnt] = malloc(toAlloc); if(list[numEnt]) { list[numEnt][ENTRY_TYPE] = pent->d_type; strcpy(&list[numEnt][ENTRY_NAME], pent->d_name); numEnt++; } else { freeDir(); closedir(pdir); return; } } } } else { closedir(pdir); return; } if(numEnt == 0) { free(list); list = NULL; } qsort(list, numEnt, sizeof(char*), compare); closedir(pdir); int i; for(i=0; i<numEnt; i++) { if(list[i][ENTRY_TYPE] == DT_REG) break; lastDir = i; } } }
void MediaObjectPrivate::setupBackendObject() { Q_Q(MediaObject); Q_ASSERT(m_backendObject); //pDebug() << Q_FUNC_INFO; #ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM QObject::connect(m_backendObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), q, SLOT(_k_stateChanged(Phonon::State, Phonon::State))); #else QObject::connect(m_backendObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), q, SIGNAL(stateChanged(Phonon::State, Phonon::State))); #endif // QT_NO_PHONON_ABSTRACTMEDIASTREAM QObject::connect(m_backendObject, SIGNAL(tick(qint64)), q, SIGNAL(tick(qint64))); QObject::connect(m_backendObject, SIGNAL(seekableChanged(bool)), q, SIGNAL(seekableChanged(bool))); #ifndef QT_NO_PHONON_VIDEO QObject::connect(m_backendObject, SIGNAL(hasVideoChanged(bool)), q, SIGNAL(hasVideoChanged(bool))); #endif //QT_NO_PHONON_VIDEO QObject::connect(m_backendObject, SIGNAL(bufferStatus(int)), q, SIGNAL(bufferStatus(int))); QObject::connect(m_backendObject, SIGNAL(finished()), q, SIGNAL(finished())); QObject::connect(m_backendObject, SIGNAL(aboutToFinish()), q, SLOT(_k_aboutToFinish())); QObject::connect(m_backendObject, SIGNAL(prefinishMarkReached(qint32)), q, SIGNAL(prefinishMarkReached(qint32))); QObject::connect(m_backendObject, SIGNAL(totalTimeChanged(qint64)), q, SIGNAL(totalTimeChanged(qint64))); QObject::connect(m_backendObject, SIGNAL(metaDataChanged(const QMultiMap<QString, QString> &)), q, SLOT(_k_metaDataChanged(const QMultiMap<QString, QString> &))); QObject::connect(m_backendObject, SIGNAL(currentSourceChanged(const MediaSource&)), q, SLOT(_k_currentSourceChanged(const MediaSource&))); // set up attributes pINTERFACE_CALL(setTickInterval(tickInterval)); pINTERFACE_CALL(setPrefinishMark(prefinishMark)); pINTERFACE_CALL(setTransitionTime(transitionTime)); switch(state) { case LoadingState: case StoppedState: case ErrorState: break; case PlayingState: case BufferingState: QTimer::singleShot(0, q, SLOT(_k_resumePlay())); break; case PausedState: QTimer::singleShot(0, q, SLOT(_k_resumePause())); break; } const State backendState = pINTERFACE_CALL(state()); if (state != backendState && state != ErrorState) { // careful: if state is ErrorState we might be switching from a // MediaObject to a ByteStream for KIO fallback. In that case the state // change to ErrorState was already suppressed. pDebug() << "emitting a state change because the backend object has been replaced"; emit q->stateChanged(backendState, state); state = backendState; } #ifndef QT_NO_PHONON_MEDIACONTROLLER for (int i = 0 ; i < interfaceList.count(); ++i) { interfaceList.at(i)->_backendObjectChanged(); } #endif //QT_NO_PHONON_MEDIACONTROLLER // set up attributes if (isPlayable(mediaSource.type())) { #ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM if (mediaSource.type() == MediaSource::Stream) { Q_ASSERT(mediaSource.stream()); mediaSource.stream()->d_func()->setMediaObjectPrivate(this); } #endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM pINTERFACE_CALL(setSource(mediaSource)); } }