예제 #1
0
void AnimationPlayer::preCommit(bool startOnCompositor)
{
    if (m_compositorState && m_compositorState->pendingAction == Start) {
        // Still waiting for a start time.
        return;
    }

    bool softChange = m_compositorState && (paused() || m_compositorState->playbackRate != m_playbackRate);
    bool hardChange = m_compositorState && (m_compositorState->sourceChanged || (m_compositorState->startTime != m_startTime && !std::isnan(m_compositorState->startTime) && !std::isnan(m_startTime)));

    // FIXME: softChange && !hardChange should generate a Pause/ThenStart,
    // not a Cancel, but we can't communicate these to the compositor yet.

    bool changed = softChange || hardChange;
    bool shouldCancel = (!playing() && m_compositorState) || changed;
    bool shouldStart = playing() && (!m_compositorState || changed);

    if (shouldCancel) {
        cancelAnimationOnCompositor();
        m_compositorState = nullptr;

    }

    if (!shouldStart) {
        m_currentTimePending = false;
    }

    if (shouldStart && startOnCompositor && maybeStartAnimationOnCompositor()) {
        m_compositorState = adoptPtr(new CompositorState(*this));
    }
}
예제 #2
0
    MediaController::MediaController(kt::MediaPlayer* player, KActionCollection* ac, QWidget* parent) : QWidget(parent)
    {
        setupUi(this);

        info_label->setText(i18n("Ready to play"));
        seek_slider->setMediaObject(player->media0bject());
        volume->setAudioOutput(player->output());
        volume->setOrientation(Qt::Horizontal);


        connect(player, SIGNAL(stopped()), this, SLOT(stopped()));
        connect(player, SIGNAL(playing(MediaFileRef)), this, SLOT(playing(MediaFileRef)));

        play->setDefaultAction(ac->action("media_play"));
        play->setAutoRaise(true);
        pause->setDefaultAction(ac->action("media_pause"));
        pause->setAutoRaise(true);
        stop->setDefaultAction(ac->action("media_stop"));
        stop->setAutoRaise(true);
        prev->setDefaultAction(ac->action("media_prev"));
        prev->setAutoRaise(true);
        next->setDefaultAction(ac->action("media_next"));
        next->setAutoRaise(true);

        setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
    }
예제 #3
0
KSB_MediaWidget::KSB_MediaWidget(QWidget *parent):KSB_MediaWidget_skel(parent)
{
	player = new Player(this);
	empty();

	QFont labelFont = time->font();
	labelFont.setPointSize(18);
	labelFont.setBold(true);
	time->setFont(labelFont);

	connect(Play, SIGNAL(clicked()), player, SLOT(play()));
	connect(Pause, SIGNAL(clicked()), player, SLOT(pause()));
	connect(Stop, SIGNAL(clicked()), player, SLOT(stop()));

	connect(player, SIGNAL(timeout()), this, SLOT(playerTimeout()));
	connect(player, SIGNAL(finished()), this, SLOT(playerFinished()));
	connect(player, SIGNAL(playing()), this, SLOT(playing()));
	connect(player, SIGNAL(paused()), this, SLOT(paused()));
	connect(player, SIGNAL(stopped()), this, SLOT(stopped()));
	connect(player, SIGNAL(empty()), this, SLOT(empty()));

	connect(Position, SIGNAL(userChanged(int)), this, SLOT(skipToWrapper(int)));
	connect(this, SIGNAL(skipTo(unsigned long)), player, SLOT(skipTo(unsigned long)));
	setAcceptDrops(true);

	pretty="";
	needLengthUpdate=false;

	QToolTip::add(Play,i18n("Play"));
	QToolTip::add(Pause,i18n("Pause"));
	QToolTip::add(Stop,i18n("Stop"));
}
예제 #4
0
void VlcMediaPlayer::emitStatus()
{
    Vlc::State s = state();
    bool audio_count;
    bool video_count;

    if (s == Vlc::Buffering ||
        s == Vlc::Playing ||
        s == Vlc::Paused) {
        audio_count = _vlcAudio->trackCount() > 0;
        video_count = _vlcVideo->trackCount() > 0;
    } else {
        audio_count = false;
        video_count = false;
    }

    VlcError::errmsg();

    emit currentState(s);
    emit hasAudio(audio_count);
    emit hasVideo(video_count);

    // Deprecated
    bool play = s == Vlc::Playing;
    bool buffering = s == Vlc::Buffering;
    emit playing(play, buffering);
}
예제 #5
0
void WorkPreviewerThread::playFile(QString file) {
    if(mFillTimer == NULL) {
        mFillTimer = new QTimer(this);
        //connect us up
        QObject::connect(mFillTimer,
                         SIGNAL(timeout()),
                         this,
                         SLOT(fillBuffer()));
    }

    mFillTimer->stop();
    try {
        if(mSoundFile)
            delete mSoundFile;
        mSoundFile = new SoundFile(file.toStdString());
        if(*mSoundFile) {
            //run every millisecond
            mFillTimer->start(1);
        } else {
            delete mSoundFile;
            mSoundFile = NULL;
            emit(playing(false));
        }
    } catch (...) {
        mSoundFile = NULL;
    }
}
예제 #6
0
파일: w_piano.cpp 프로젝트: an146/vomid
void
WPiano::capture_mouse(bool capture)
{
	if (capture == mouse_captured_)
		return;
	if (capture && playing())
		return;

	if (capture) {
#ifdef Q_WS_WIN
		QRect v = viewport();
		QPoint p1 = mapToGlobal(v.topLeft());
		QPoint p2 = mapToGlobal(v.bottomRight());
		RECT rect = {p1.x(), p1.y(), p2.x(), p2.y()};
		ClipCursor(&rect);

		// be sure that cursor doesn't reach the clip boundary
		update_timer_.start(update_freq, this);
#else
		grabMouse();
#endif
		drop_pivot();
		setCursor(Qt::BlankCursor);
	} else {
#ifdef Q_WS_WIN
		ClipCursor(NULL);
		update_timer_.stop();
#else
		releaseMouse();
#endif
		setCursor(Qt::ArrowCursor);
	}
	mouse_captured_ = capture;
	setMouseTracking(mouse_captured_);
}
예제 #7
0
bool SoundManager::isFinished(WSound *sound) const
{
  if (current_ == sound)
    return !playing();
  else
    return true;
}
예제 #8
0
void PlayerGst::timerUpdate()
{
	GstMessage* message;
	while(!usePlaybin && (message = gst_bus_pop(bus), message)) {
		switch (GST_MESSAGE_TYPE (message)) {
		case GST_MESSAGE_ERROR: {
			GError *err;
			gchar *debug;
			gst_message_parse_error (message, &err, &debug);
			QString str;
			str = "Error #"+QString::number(err->code)+" in module "+QString::number(err->domain)+"\n"+QString::fromUtf8(err->message);
			if(err->code == 6 && err->domain == 851) {
				str += "\nMay be you should to install gstreamer0.10-plugins-ugly or gstreamer0.10-plugins-bad";
			}
			QMessageBox::warning(0, "Gstreamer error", str);
			g_error_free (err);
			g_free (debug);
			break;
		}
		case GST_MESSAGE_EOS:
			need_finish();
			//QMessageBox::information(0, "", "EOS");
			return;
		default:
			break;
		}
	}
    if(playing()) {
		gint64 p;
		GstFormat fmt = GST_FORMAT_TIME;
		gst_element_query_position(pipeline, &fmt, &p);
		emit position((double)(p - Gstart) / Glength);
    }
}
예제 #9
0
AUD_Handle* AUD_SoftwareDevice::play(AUD_IReader* reader, bool keep)
{
	// prepare the reader
	reader = m_mixer->prepare(reader);
	if(reader == NULL)
		return NULL;

	// play sound
	AUD_SoftwareHandle* sound = new AUD_SoftwareHandle;
	sound->keep = keep;
	sound->reader = reader;
	sound->volume = 1.0f;
	sound->loopcount = 0;
	sound->stop = NULL;
	sound->stop_data = NULL;

	lock();
	m_playingSounds.push_back(sound);

	if(!m_playback)
		playing(m_playback = true);
	unlock();

	return sound;
}
예제 #10
0
bool AUD_SoftwareDevice::resume(AUD_Handle* handle)
{
	bool result = false;

	lock();

	// only songs that are paused can be resumed
	for(AUD_HandleIterator i = m_pausedSounds.begin();
		i != m_pausedSounds.end(); i++)
	{
		if(*i == handle)
		{
			m_playingSounds.push_back(*i);
			m_pausedSounds.erase(i);
			if(!m_playback)
				playing(m_playback = true);
			result = true;
			break;
		}
	}

	unlock();

	return result;
}
예제 #11
0
void AUD_SoftwareDevice::destroy()
{
	if(m_playback)
		playing(m_playback = false);

	delete m_mixer;

	AUD_SoftwareHandle* handle;

	// delete all playing sounds
	while(!m_playingSounds.empty())
	{
		handle = m_playingSounds.front();
		m_playingSounds.pop_front();
		delete handle->reader;
		delete handle;
	}

	// delete all paused sounds
	while(!m_pausedSounds.empty())
	{
		handle = m_pausedSounds.front();
		m_pausedSounds.pop_front();
		delete handle->reader;
		delete handle;
	}

	pthread_mutex_destroy(&m_mutex);
}
예제 #12
0
void AnimationPlayer::play()
{
    PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);

    if (!playing())
        m_startTime = nullValue();

    if (playStateInternal() == Idle) {
        // We may not go into the pending state, but setting it to something other
        // than Idle here will force an update.
        ASSERT(isNull(m_startTime));
        m_playState = Pending;
        m_held = true;
        m_holdTime = 0;
    }

    m_finished = false;
    unpauseInternal();
    if (!m_content)
        return;
    double currentTime = this->currentTimeInternal();
    if (m_playbackRate > 0 && (currentTime < 0 || currentTime >= sourceEnd()))
        setCurrentTimeInternal(0, TimingUpdateOnDemand);
    else if (m_playbackRate < 0 && (currentTime <= 0 || currentTime > sourceEnd()))
        setCurrentTimeInternal(sourceEnd(), TimingUpdateOnDemand);
}
예제 #13
0
void CritterObject::think()
{
    if (movementQueue()->size() > 0)
    {
        if (!_moving)
        {
            _moving = true;

            delete _ui;
            _orientation = hexagon()->orientationTo(movementQueue()->back());
            auto animation = _generateMovementAnimation();
            animation->setActionFrame(_running ? 2 : 4);
            animation->addEventHandler("actionFrame",    std::bind(&CritterObject::onMovementAnimationEnded, this, std::placeholders::_1));
            animation->addEventHandler("animationEnded", std::bind(&CritterObject::onMovementAnimationEnded, this, std::placeholders::_1));
            animation->play();
            _ui = animation;
        }
    }
    else
    {
        auto anim = (UI::Animation*)ui();
        if (!_moving && (!anim || !anim->playing()))
        {
            if (SDL_GetTicks() > _nextIdleAnim)
            {
                setActionAnimation("aa");
                _setupNextIdleAnim();
            }
        }
    }
    Object::think();
}
예제 #14
0
파일: dynamicplaylist.cpp 프로젝트: KDE/juk
void DynamicPlaylist::lower(QWidget *top)
{
    if(top == this)
        return;

    if(playing()) {
        PlaylistList l;
        l.append(this);
        for(PlaylistList::Iterator it = m_playlists.begin();
            it != m_playlists.end(); ++it)
        {
            (*it)->synchronizePlayingItems(l, true);
        }
    }

    PlaylistItemList list = PlaylistItem::playingItems();
    for(PlaylistItemList::Iterator it = list.begin(); it != list.end(); ++it) {
        if((*it)->playlist() == this) {
            list.erase(it);
            break;
        }
    }

    if(!list.isEmpty())
        TrackSequenceManager::instance()->setCurrentPlaylist(list.front()->playlist());
}
예제 #15
0
ClipRenderer::ClipRenderer() :
    GenericRenderer(),
    m_clipLoaded( false ),
    m_vlcMedia( NULL ),
    m_selectedClip( NULL ),
    m_begin( 0 ),
    m_end( -1 ),
    m_mediaChanged( false )
{
    connect( m_mediaPlayer,     SIGNAL( stopped() ),            this,   SLOT( __videoStopped() ) );
    connect( m_mediaPlayer,     SIGNAL( paused() ),             this,   SIGNAL( paused() ) );
    connect( m_mediaPlayer,     SIGNAL( playing() ),            this,   SIGNAL( playing() ) );
    connect( m_mediaPlayer,     SIGNAL( volumeChanged() ),      this,   SIGNAL( volumeChanged() ) );
    connect( m_mediaPlayer,     SIGNAL( timeChanged( qint64 ) ),this,   SLOT( __timeChanged( qint64 ) ) );
    connect( m_mediaPlayer,     SIGNAL( endReached() ),         this,   SLOT( __endReached() ) );
}
예제 #16
0
파일: StateManager.cpp 프로젝트: ace13/ld26
void StateManager::Internals::addedToEntity()
{
    StateManager* man = &mState;

    requestMessage("Get.Input",    [man](Kunlaboro::Message& msg){ msg.payload = man->mInput; msg.handled = true;    });
    requestMessage("Get.Settings", [man](Kunlaboro::Message& msg){ msg.payload = man->mSettings; msg.handled = true; });
    requestMessage("Get.Sounds",   [man](Kunlaboro::Message& msg){ msg.payload = man->mSound; msg.handled = true;    });
    requestMessage("Get.Font",     [man](Kunlaboro::Message& msg){ msg.payload = &man->mGlobalFont; msg.handled = true; });
    requestMessage("Get.GameView", [man](Kunlaboro::Message& msg){ msg.payload = man->mGameView; msg.handled = true; });
    requestMessage("Get.UiView",   [man](Kunlaboro::Message& msg){ msg.payload = man->mUiView; msg.handled = true;   });

    requestMessage("Now Playing",  [this](const Kunlaboro::Message& msg)
    {
        mCurrentSong = boost::any_cast<std::string>(msg.payload);
        mSongPopout = 0;
        mSongTimeout = 2;
    });
    requestMessage("LD26.Update",  [this](const Kunlaboro::Message& msg)
    {
        float dt = boost::any_cast<float>(msg.payload);

        if (mSongTimeout > 0)
            mSongTimeout = std::max(0.f, mSongTimeout - dt);

        if (!mCurrentSong.empty() && mSongTimeout > 0 && mSongPopout < 1)
            mSongPopout = std::min(1.f, mSongPopout + dt);
        else if (mSongTimeout == 0 && mSongPopout > 0)
            mSongPopout = std::max(0.f, mSongPopout - dt);
        else if (mSongTimeout == 0 && mSongPopout == 0 && !mCurrentSong.empty())
            mCurrentSong.clear();
    });
    changeRequestPriority("LD26.Update", -11);
    requestMessage("LD26.DrawUi",  [this](const Kunlaboro::Message& msg)
    {
        sf::RenderTarget& target = *boost::any_cast<sf::RenderTarget*>(msg.payload);

        sf::RectangleShape rect;
        rect.setSize(sf::Vector2f(512, 96));
        rect.setOrigin(rect.getSize()/2.f);
        rect.setFillColor(sf::Color::Black);
        rect.setOutlineColor(sf::Color::White);
        rect.setOutlineThickness(6.f);

        rect.setPosition(target.getSize().x + 262 - (512 * mSongPopout), target.getSize().y - 100);

        target.draw(rect);

        sf::Text playing("Now Playing:", mState.mGlobalFont);
        sf::FloatRect bounds = playing.getLocalBounds();
        playing.setPosition(rect.getPosition() - sf::Vector2f(350, 72) + sf::Vector2f(bounds.left + bounds.width/2, bounds.top + bounds.height/2));

        target.draw(playing);
        playing.setString(mCurrentSong);
        playing.move(0, bounds.height + 16);
        playing.setCharacterSize(20U);

        target.draw(playing);
    });
}
예제 #17
0
bool AnimationPlayer::canStartAnimationOnCompositor()
{
    // FIXME: Need compositor support for playback rate != 1.
    if (playbackRate() != 1)
        return false;

    return m_timeline && m_content && m_content->isAnimation() && playing();
}
예제 #18
0
bool AnimationPlayer::canStartAnimationOnCompositor()
{
    // FIXME: Timeline playback rates should be compositable
    if (m_playbackRate == 0 || (std::isinf(sourceEnd()) && m_playbackRate < 0) || (timeline() && timeline()->playbackRate() != 1))
        return false;

    return m_timeline && m_content && m_content->isAnimation() && playing();
}
예제 #19
0
void AudioBody::notifyReloaded (const DiskResource *r)
{
    (void) r;
    bool was_playing = playing();
    if (was_playing) stop();
    reinitialise();
    if (was_playing) play();
}
예제 #20
0
파일: w_piano.cpp 프로젝트: an146/vomid
void
WPiano::playStarted()
{
	if (playing()) {
		capture_mouse(false);
		update_timer_.start(update_freq, this);
	}
}
예제 #21
0
void Simpleton::noteOff(const int32_t note) {
  if (playing()) {
		Source *source = noteList.getSource(note);
		if (source != NULL) {
			source->noteOff();
		}
  }
}
void TuneListenerFile::check()
{
    TuneData existedTune = FCurrentTune;
    FCurrentTune.clear(); // just a reset
    if (QFile::exists(FFileName))
    {
        QFile file(FFileName);
        if (file.open(QIODevice::ReadOnly))
            switch (FFileFormat)
            {
                case Plain:
                {
                    QTextStream stream( &file );
                    stream.setCodec("UTF-8");
                    stream.setAutoDetectUnicode(true);
                    FCurrentTune.title = stream.readLine();
                    FCurrentTune.artist = stream.readLine();
                    FCurrentTune.source = stream.readLine();
                    FCurrentTune.track = stream.readLine();
                    FCurrentTune.length = stream.readLine().toInt();
                    break;
                }

                case XML:
                {
                    QDomDocument d;
                    d.setContent(&file, false);
                    QDomElement now_playing=d.documentElement();
                    QDomElement song=now_playing.firstChildElement("song");
                    if (!song.firstChildElement("title").text().isNull())
                        FCurrentTune.title = song.firstChildElement("title").text();
                    if (!song.firstChildElement("artist").text().isNull())
                        FCurrentTune.artist = song.firstChildElement("artist").text();
                    if (!song.firstChildElement("album").text().isNull())
                        FCurrentTune.source = song.firstChildElement("album").text();
                    if (!song.firstChildElement("track").text().isNull())
                        FCurrentTune.track = song.firstChildElement("track").text();
                    if (!song.firstChildElement("length").text().isNull())
                        FCurrentTune.length = song.firstChildElement("length").text().toInt();
                }
            }
    }
    else if (!FWaitForCreated && existedTune.isEmpty())
    {
        FWaitForCreated = true;
        return; // we will return to this function when file created. just exit for now.
    }
    // Common code
    TuneData tune = currentTune();
    if (FPreviousTune != tune)
    {
        FPreviousTune = tune;
        if (tune.isEmpty())
            emit stopped();
        else
            emit playing(tune);
    }
}
예제 #23
0
bool Animation::preCommit(int compositorGroup, bool startOnCompositor)
{
    PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand, DoNotSetCompositorPending);

    bool softChange = m_compositorState && (paused() || m_compositorState->playbackRate != m_playbackRate);
    bool hardChange = m_compositorState && (m_compositorState->effectChanged || m_compositorState->startTime != m_startTime);

    // FIXME: softChange && !hardChange should generate a Pause/ThenStart,
    // not a Cancel, but we can't communicate these to the compositor yet.

    bool changed = softChange || hardChange;
    bool shouldCancel = (!playing() && m_compositorState) || changed;
    bool shouldStart = playing() && (!m_compositorState || changed);

    if (startOnCompositor && shouldCancel && shouldStart && m_compositorState && m_compositorState->pendingAction == Start) {
        // Restarting but still waiting for a start time.
        return false;
    }

    if (shouldCancel) {
        cancelAnimationOnCompositor();
        m_compositorState = nullptr;
    }

    ASSERT(!m_compositorState || !std::isnan(m_compositorState->startTime));

    if (!shouldStart) {
        m_currentTimePending = false;
    }

    if (shouldStart) {
        m_compositorGroup = compositorGroup;
        if (startOnCompositor) {
            if (isCandidateForAnimationOnCompositor())
                createCompositorPlayer();

            if (maybeStartAnimationOnCompositor())
                m_compositorState = adoptPtr(new CompositorState(*this));
            else
                cancelIncompatibleAnimationsOnCompositor();
        }
    }

    return true;
}
예제 #24
0
파일: audio.cpp 프로젝트: KDE/klook
void Audio::play_or_pause()
{
    if (playing()) {
        pause();
    }
    else {
        play();
    }
}
예제 #25
0
파일: sound.cpp 프로젝트: Phaeodaria/abuse
song::~song()
{
    if(playing())
        stop();
    free(data);
    free(Name);

    Mix_FreeMusic(music);
    SDL_FreeRW(rw);
}
예제 #26
0
 bool AudioStream_Ogg::isActive()
 {
    //#ifdef ANDROID
    // TODO: Android stream sounds won't resume :(
    //if (mSuspend) return false;
    //#else
    if (mSuspend) return true;
    //#endif
    //playback();
    return (mIsValid && playing());
 }
예제 #27
0
void MusicPlayer::changeTime()
{
	if (scheduledTime >= 0) {
		qDebug("Changing position to %d", scheduledTime);
		vlcPlayer->setTime(scheduledTime);
		scheduledTime = -1; // reset
		disconnect(vlcPlayer, SIGNAL(playing()), this, SLOT(changeTime()));
	} else {
		qDebug("Error: there is no currently scheduled position!");
	}
}
예제 #28
0
bool Animation::canStartAnimationOnCompositor() const
{
    if (m_isCompositedAnimationDisabledForTesting)
        return false;

    // FIXME: Timeline playback rates should be compositable
    if (m_playbackRate == 0 || (std::isinf(effectEnd()) && m_playbackRate < 0) || (timeline() && timeline()->playbackRate() != 1))
        return false;

    return m_timeline && m_content && m_content->isKeyframeEffect() && playing();
}
예제 #29
0
void AnimationPlayer::pause()
{
    if (m_paused)
        return;
    if (playing()) {
        setCompositorPending();
        m_currentTimePending = true;
    }
    m_paused = true;
    setCurrentTimeInternal(currentTimeInternal(), TimingUpdateOnDemand);
}
예제 #30
0
void SoftwareDevice::destroy()
{
	if(m_playback)
		playing(m_playback = false);

	while(!m_playingSounds.empty())
		m_playingSounds.front()->stop();

	while(!m_pausedSounds.empty())
		m_pausedSounds.front()->stop();
}