Beispiel #1
0
 void MainWindow::saveFilterToFile(const std::string &fileName) {
   setPlaying(true);
   setPlaying(false);
   std::ofstream outputFile(fileName);
   outputFile << imageAfterArea.getOutput();
   outputFile.close();
 }
Beispiel #2
0
void Plotter::handlePlay(bool checked)
{
	if(m_playing || !canPlay())
		setPlaying(false);
	else
		setPlaying(true);
}
Beispiel #3
0
void Timeline::playPause(){
    if(getPlaying()) {
        setPlaying(false);
    } else {
        setPlaying(true);
    }
}
Beispiel #4
0
unsigned STexture::updateCurrentFrame()
{
    if (!videoReady()) return 0;

    if (isPlaying()) {
        double elapsed = lastFrameTime.restart()/1000.0;
        position += elapsed*fps;
    }

    if (loopFromFrame < firstFrame || loopFromFrame>= lastFrame)
        loopFromFrame = firstFrame;

    // this can happend if fps is negative.
    if (position < firstFrame) {
        if (loop) {
            position =  lastFrame-fmod(firstFrame-position, 1+lastFrame-firstFrame);
            assert(position >= firstFrame && position <= lastFrame);
        } else {
            position = firstFrame;
            setPlaying(false);
        }
    }
    if (position > lastFrame) {
        if (loop) {
            position = fmod(position-loopFromFrame, 1+lastFrame-loopFromFrame) + loopFromFrame;
            assert(position >= firstFrame && position <= lastFrame);
        } else {
            position = lastFrame;
            setPlaying(false);
        }
    }
    return getCurrentFrame();
}
Beispiel #5
0
void PlaylistModel::onPlaybackStateChanged(MPD_PLAYBACK_STATE state)
{
    mPlaybackState = state;
    if ( mPlaybackState == MPD_STOP ) {
        // Unset playing flag for last track played
        setPlaying(mTrackNo,false);
    } else {
        setPlaying(mTrackNo, true);
    }
}
Beispiel #6
0
void PlaylistModel::onTrackNoChanged(quint32 trackNo)
{
    // Check boundaries
    if ( trackNo >= (quint32)rowCount() ) {
        mTrackNo = trackNo;
        return;
    }

    // Change track playing flags
    setPlaying(mTrackNo, false);
    mTrackNo = trackNo;
    setPlaying(mTrackNo, true);
}
void SuperColliderLoopElement::guiEvent(ofxUIEventArgs &e) {
    if (e.getName() == "Play") {
        setPlaying(isPlay);
    }
    else if (e.getName() == "Rec") {
        setToRecord(toRecord);
    }
    else if (e.getName() == "Solo") {
        setSolo(solo);
        SuperColliderLoopElement *ref = this;
        ofNotifyEvent(soloEvent, ref);
    }
    else if (e.getName() == "Del") {
        SuperColliderLoopElement *ref = this;
        ofNotifyEvent(deleteEvent, ref);
    }
    else if (e.getName() == "Skip") {
        skip = pow((float) 2, (float) ((ofxUIRadio *) gui->getWidget("Skip"))->getValue());
        count = beat % (numBeats * getSkip());
    }
    else if (e.getName() == "BusIn") {
        int channel = ((ofxUIRadio *) gui->getWidget("BusIn"))->getValue();
        bufWriter->set("channel", channel);
    }
    else if (e.getName() == "Volume") {
        cout << "write vol " << volume << endl;
        bufReader->set("volume", volume);
    }
}
	bool MainWindow::event(QEvent *event)
	{
		if (event->type() == UPDATEEVENT)
		{
			UpdateEvent *e = (UpdateEvent*)event;

			e->mtx_updateEvent->lock();
			updateFrameChannel();

			e->cond_updateEvent->notify_all();
			e->mtx_updateEvent->unlock();
			return true;
		}
		else if (event->type() == CALLBACKEVENT)
		{
			CallbackEvent *e = (CallbackEvent*)event;

			if (e->callback != NULL)
			{
				(*e->callback)(this, e->callback_data);
			}
			return true;
		}
		else if (event->type() == ISPLAYINGSONGEVENT)
		{
			IsPlayingSongEvent *e = (IsPlayingSongEvent*)event;

			setPlaying(e->playing);
			return true;
		}

		return QMainWindow::event(event);
	}
void PlaybackController::stopExporter()
{
	Q_ASSERT(m_exporter);
	if(isPlaying())
		setPlaying(false);
	m_exporter->finish();
}
Beispiel #10
0
void AudioPlayer::play(PModel playlistModel, const QModelIndex& index)
{
    if (!index.isValid())
        return;
    PTrack currentlyPlayingTrack = playingTrack_;
    setPlaying(playlistModel, index);
    setBuffering(PModel(), QModelIndex());
    if (!playingTrack_)
        return;

    if (currentlyPlayingTrack && audioOutput_->state() == AudioState::Playing && currentlyPlayingTrack->isCueTrack() && playingTrack_->isCueTrack()
        && currentlyPlayingTrack->location == playingTrack_->location) {
        // Playing in the same cue file
        audioOutput_->seek(playingTrack_->cueOffset());
        emit trackPlaying(playingTrack_);
        emit trackPositionChanged(0, true);
    } else {
        audioOutput_->clearQueue();
        audioOutput_->setCurrentSource(playingTrack_->location);
        setVolume(volume_);
        if (playingTrack_->isCueTrack()) {
            audioOutput_->play(playingTrack_->cueOffset());
        }
        else
            audioOutput_->play();
    }
}
void QSoundEffectPrivate::stop()
{
    if (m_timerID != 0)
        killTimer(m_timerID);
    m_timerID = 0;
    m_sound->stop();
    setPlaying(false);
}
void QSoundEffectPrivate::play()
{
    if (m_timerID != 0)
        killTimer(m_timerID);
    m_timerID = startTimer(500);
    m_sound->play();
    setPlaying(true);
}
void QSoundEffectPrivate::stateChanged(QMediaPlayer::State state)
{
    if (state == QMediaPlayer::StoppedState) {
        if (m_runningCount < 0) {
            m_player->play();
        } else if (m_runningCount == 0) {
            setPlaying(false);
            return;
        } else if (--m_runningCount > 0) {
            m_player->play();
        } else {
            setPlaying(false);
        }
    } else {
        setPlaying(true);
    }
}
void QSoundEffectPrivate::timerEvent(QTimerEvent *event)
{
    setPlaying(!m_sound->isFinished());
    if (isPlaying())
        return;
    killTimer(m_timerID);
    m_timerID = 0;
}
Beispiel #15
0
void QDeclarativeVideo::stop()
{
    if (!m_complete)
        return;

    setPlaying(false);
    setPaused(false);
}
Beispiel #16
0
void QDeclarativeVideo::pause()
{
    if (m_playerControl == 0)
        return;

    setPaused(true);
    setPlaying(true);
}
Beispiel #17
0
void QDeclarativeVideo::stop()
{
    if (m_playerControl == 0)
        return;

    setPlaying(false);
    setPaused(false);
}
Beispiel #18
0
void QDeclarativeVideo::pause()
{
    if (!m_complete)
        return;

    setPaused(true);
    setPlaying(true);
}
void QDeclarativeAudio::play()
{
    if (!m_complete)
        return;

    setPaused(false);
    setPlaying(true);
}
Beispiel #20
0
void AudioPlayer::deletePlaylist(PModel model)
{
    queue_.removePlaylistModel(model);
    playlists_.erase(model);
    if (playingModel_ == model)
        setPlaying(PModel(), QModelIndex());
    if (bufferingTrackPlaylist_ == model)
        setBuffering(PModel(), QModelIndex());
}
void PlaybackController::stopExporter()
{
	if(isPlaying())
		setPlaying(false);
	if(m_exporter)
		m_exporter->finish();
	else
		qWarning("stopExporter(): exported not active!");
}
void PlaybackController::exporterError(const QString &message)
{
	// Stop playback on error
	if(isPlaying())
		setPlaying(false);

	emit exportError(message);

	exporterFinished();
}
Beispiel #23
0
void YVPlayer::saveFile(QNetworkReply* reply) {
    QString t = "tmp_"+QString::number(qHash(reply->url())) + ".mp3";
    m_t = t;
    QFile f(qgetenv("HOME") + "/" + t);
    f.open(QFile::WriteOnly);
    f.write(reply->readAll());
    m_reply = 0;
    reply->deleteLater();
    setPlaying(true);
}
Beispiel #24
0
void Plotter::updatePlayEnabled()
{
	if(canPlay())
		m_ui->playButton->setEnabled(true);
	else
	{
		m_ui->playButton->setEnabled(false);
		setPlaying(false);
	}
}
bool QSoundEffectPrivate::isPlaying()
{
    if (m_playing && m_sound && m_sound->isFinished()) {
        if (m_timerID != 0)
            killTimer(m_timerID);
        m_timerID = 0;
        setPlaying(false);
    }
    return m_playing;
}
void QSoundEffectPrivate::play()
{
    if (m_status == QSoundEffect::Null || m_status == QSoundEffect::Error)
        return;
    if (m_timerID != 0)
        killTimer(m_timerID);
    m_timerID = startTimer(500);
    m_sound->play();
    setPlaying(true);
}
Beispiel #27
0
void Animation::play() {
	if (isPlaying()) {
		return;
	}

	// Mark the first frame dirty so it gets displayed
	markDirtyRect(_vm->_screen->getSurface());

	setPlaying(true);

	debugC(3, kDraciAnimationDebugLevel, "Playing animation %d...", getID());
}
void PlaybackController::exporterError(const QString &message)
{
	// Stop playback on error
	if(isPlaying())
		setPlaying(false);

	// Show warning message
	// TODO move this away from here
	QMessageBox::warning(0, tr("Video error"), message);

	exporterFinished();
}
void QSoundEffectPrivate::stop()
{
    if (!d->m_playing)
        return;
#ifdef QT_QAUDIO_DEBUG
    qDebug() << "stop()";
#endif
    d->m_offset = 0;

    setPlaying(false);

    if (d->m_audioOutput)
        d->m_audioOutput->stop();
}
SuperColliderLoopElement::SuperColliderLoopElement(SuperCollider * sc3, int numBeats, int index){
    int BPM = 120;
    
    this->numBeats = numBeats;
    this->volume = 1.0;
    this->skip = 1;
    this->count = 0;
    this->solo = false;
    this->mute = false;
    
    // supercollider stuff
    buffer = sc3->addBuffer("buffer"+ofToString(ofRandom(10000)), 44100 * (numBeats * 60.0f / BPM), 1);
    bufWriter = sc3->addSynth("buf_recorder");
    bufReader = sc3->addSynth("buf_player");
    bufWriter->set("bufnum", buffer->index);
    bufReader->set("bufnum", buffer->index);
    
    // create gui
    vector<string> inputItems, skipItems;
    inputItems.push_back("1");
    inputItems.push_back("2");
    skipItems.push_back("1");
    skipItems.push_back("2");
    skipItems.push_back("4");
    skipItems.push_back("8");
    gui = new ofxUICanvas("Track");
    gui->setPosition(5, 55 + 32 * index);
    gui->clearWidgets();
    gui->addLabel("Channel:");
    gui->setWidgetPosition(OFX_UI_WIDGET_POSITION_RIGHT);
    gui->addRadio("BusIn", inputItems, OFX_UI_ORIENTATION_HORIZONTAL)->getToggles()[0]->setValue(true);
    gui->addLabel("Play:");
    gui->addLabelToggle("Play", &isPlay, 42.0f);
    gui->addLabelToggle("Rec", &toRecord, 42.0f);
    gui->addLabelToggle("Solo", &solo, 42.0f);
    gui->addLabelButton("Del", false, 42.0f);
    gui->addLabel("Each:");
    gui->addRadio("Skip", skipItems, OFX_UI_ORIENTATION_HORIZONTAL)->getToggles()[0]->setValue(true);
    gui->addMinimalSlider("Volume", 0.0f, 1.0f, &volume, 60.0f, 16.0f);
    gui->addLabel("Time:");
    progressSlider = gui->addMinimalSlider("", 0.0, 1.0, 0.0);
    progressSlider->getRect()->setWidth(20 * numBeats);
    gui->autoSizeToFitWidgets();
    gui->getRect()->setWidth(ofGetWidth()-10);
    ofAddListener(gui->newGUIEvent, this, &SuperColliderLoopElement::guiEvent);
    setPlaying(false);
    setRecording(false);
}