Ejemplo n.º 1
0
void KNMusicBackendBassThread::setPosition(const qint64 &position)
{
    //Check the channel is null.
    if(!m_channel)
    {
        return;
    }
    //If the state is stopped and the position is not 0, then changed the state
    //to pause.
    if(m_state==Stopped && position!=0)
    {
        //Change to paused.
        setPlayingState(Paused);
    }
    //Change the position, the unit of the position should be translate into
    //second.
    BASS_ChannelSetPosition(
                m_channel,
                BASS_ChannelSeconds2Bytes(m_channel,
                                          //The position here should be the
                                          //'absolute' position.
                                          //That means it should be the position
                                          //plus the start position.
                                          (double)(m_startPosition+position)
                                          /1000.0),
                BASS_POS_BYTE);
    //Check the position.
    checkPosition();
}
Ejemplo n.º 2
0
void KNMusicBackendBassThread::play()
{
    //Check:
    // 1. The state is already playing.
    // 2. The channel is null.
    if(m_state==Playing || (!m_channel))
    {
        return;
    }
    //Start the position updater.
    m_positionUpdater->start();
    //Check the playing state before.
    if(m_state==Stopped)
    {
        //Reset the position to fit track playing.
        setPosition(0);
        //Set the volume to the last volume, because of the reset, the
        //volume is back to 1.0.
        BASS_ChannelSetAttribute(m_channel, BASS_ATTRIB_VOL, m_volume);
    }
    //Play the thread.
    BASS_ChannelPlay(m_channel, FALSE);
    //Update the state.
    setPlayingState(Playing);
}
Ejemplo n.º 3
0
void TvrUiWidget::stopMedia(){


    if(getRecordingState() || getRecordingPausedState()){
        tvr_stop_recorder_pipeline(rd);
        if(rd){
            g_free(rd);
            rd = NULL;
        }
        setRecordingState(false);
        setRecordingPausedState(false);
        setLastRecording(true);
    }

    if(getPlayingState() || getPlayingPausedState()){
        tvr_stop_player_pipeline(pd);
        if(pd){
            g_free(pd);
            pd = NULL;
        }

        if(playButtonClicked){
            playButtonClicked = false;
        }
        setPlayingState(false);
        setPlayingPausedState(false);
    }
        // Stop Timer
        t->stop();

        // Values need to be reset
        progBarValue = 0;
        retValue = 100;
        count = 0;
        seconds = 0;

        // Progress Bar needs to be reset
        tvrProgressBar->setValue(0);
        lengthFieldEditLabel->setText("0");

        // Close all states
        setFileOpenedState(false);
        setFileSaveState(false);

        // Set Buttons Status
        setButtonStatus(true, true, false, false, true, true);

        statusLabelEdit->setText("Stopped");


}
Ejemplo n.º 4
0
void TvrUiWidget::playMedia(){


        statusLabelEdit->setText("Playing ...");

        setPlayingPausedState(false);
        setPlayingState(true);

        setButtonStatus(false, false, true, true, true, true);

        if(tvr_play_player_pipeline(pd) == GST_MESSAGE_EOS){
                stopMedia();
        }

}
Ejemplo n.º 5
0
void KNMusicBackendBassThread::pause()
{
    //Check:
    // 1. The state is already paused.
    // 2. The channel is null.
    if(m_state==Paused || (!m_channel))
    {
        return;
    }
    //Pause the thread.
    BASS_ChannelPause(m_channel);
    //Stop the updater.
    m_positionUpdater->stop();
    //Reset the state.
    setPlayingState(Paused);
}
Ejemplo n.º 6
0
void KNMusicBackendBassThread::reset()
{
    //Stop the position updater.
    m_positionUpdater->stop();
    //Clear up the channel sync handle.
    removeChannelSyncs();
    //Check if the channel is not null.
    freeChannel();
    //Reset the channel data.
    m_filePath.clear();
    //Reset the total duration.
    m_totalDuration=-1;
    //Reset the stream status data.
    resetChannelInformation();
    //Check the current state is stopped or not.
    setPlayingState(Stopped);
}
Ejemplo n.º 7
0
void TvrUiWidget::on_actionPaused_triggered(){

        if(getRecordingState()){
                setRecordingState(false);
                setRecordingPausedState(true);
                statusLabelEdit->setText("Recording : Paused");
                setButtonStatus(true, false, false, true, true, true);
                tvr_pause_recorder_pipeline(rd);
        }

        if(getPlayingState()){
                setPlayingState(false);
                setPlayingPausedState(true);
                statusLabelEdit->setText("Playing : Paused");
                setButtonStatus(false, true, false, true, true, true);
                tvr_pause_player_pipeline(pd);
        }

}
Ejemplo n.º 8
0
void KNMusicBackendBassThread::stop()
{
    //Check:
    // 1. The state is already stopped.
    // 2. The channel is null.
    if(m_state==Stopped || (!m_channel))
    {
        return;
    }
    //Stop the channel.
    BASS_ChannelStop(m_channel);
    //Stop the position updater.
    m_positionUpdater->stop();
    //Reset the position to the start position.
    setPosition(0);
    //Update the state.
    setPlayingState(Stopped);
    //Emit stopped signal.
    emit stopped();
}