Beispiel #1
0
void Sound::stopTrack(){
#if(NUM_CHANNELS > 0)
	for(uint8_t i=0; i<NUM_CHANNELS; i++){
		stopTrack(i);
	}
#endif
}
Beispiel #2
0
void Tune::playPrev()
{
	char filename[13] = "";
	int charCount = 0;
	int i;
	
	track.getName(filename, 13); // get current filename
		
	for (i=0; i<=nb_track; i++) // look in the tracklist
	{
		for (int j=0; j<13; j++)
		{
			if (filename[j] == tracklist[i][j]) charCount++;
			else break; // move on if a single character differs
		}
		if (charCount == 13) break; // found current track in the list, exit loop
		else charCount = 0; // reset for next turn
	}
	stopTrack(); // stop current track
	
	if (i > 0) i--; // search for next track
	else i = nb_track-1; // wrap around
	
	for (int j=0; j<13; j++)
		filename[j] = tracklist[i][j];
	
	play(filename); // and play said file
}
Beispiel #3
0
// ----------------------------------------------------------------------------
//
void SpotifyEngine::previousTrack()
{
    CSingleLock lock( &m_mutex, TRUE );

    if ( m_current_track && getTrackPlayTime() > 10*1000 ) {    // If current track > 10 seconds in, return to start
        if ( m_track_played_queue.size() )
            m_track_played_queue.pop_back();

        playTrack( m_current_track, 0L ); 
    }
    else if ( m_track_played_queue.size() ) {
        if ( m_current_track ) {                                // Skip over currently playing track (re-queue it)
            TrackQueueEntry track = m_track_played_queue.back();
            m_track_played_queue.pop_back();
            m_track_queue.push_front( track );
        }

        if ( m_track_played_queue.size() ) {
            TrackQueueEntry track = m_track_played_queue.back();
            m_track_played_queue.pop_back();
            playTrack( track.m_track, 0L ); 
        }
        else {                                                  // Current track was the only track in the played queue
            stopTrack();

            sendTrackQueueEvent();
        }
    }
}
Beispiel #4
0
void MainWindow::logout() {
    stopTrack();
    QJsonObject params;
    params["token"] = MainWindow::sharedData()->token();
    networkManager->sendJWT(LOGOUT_API_URL, params, "get")->setObjectName("logout");

    QSettings settings("WawJob", "WawTracker");
    settings.remove("remember");
    settings.remove("token");
    settings.remove("username");

    // LogOut Process
    this->isLogin = false;
    this->hide();
    this->updateActionsStatus();

    // Show Login Dialog
    LoginDialog loginDlg;
    if (loginDlg.exec() == QDialog::Accepted){
        this->isLogin = true;
        this->show();
        this->updateActionsStatus();
        this->updateUserDataComponent();
    } else {
        exit(1);
    }
}
Beispiel #5
0
void MainWindow::trackBtnClicked() {
    if (isTracking) {
        stopTrack();
    } else {
        startTrack();
    }
}
Beispiel #6
0
void Audio::startTrack(const std::string &trackName)
{
    //std::cout << "startTrack()" << std::endl;
	stopTrack();	//stop any existing music

	if (_opt._bMusic && trackName.length() > 0)
	{
		printf("Play: %s\n", trackName.c_str());
		std::string newTrack = _baseTrackDir + "/" + trackName;
        Mix_FreeMusic(_musicTrack);
		_musicTrack = Mix_LoadMUS(newTrack.c_str());
		if(_musicTrack)
		{
			Mix_PlayMusic(_musicTrack, 1);
			_bPlayingTrack = isActuallyPlayingMusic();	//actualy playing?
		}
		else
			printf("Failed to start track %s (%s)\n", newTrack.c_str(), Mix_GetError());

		Mix_HookMusicFinished(AudioTrackDone);	//reiterate callback
	}
	if (!_bPlayingTrack)
	{
		//TODO: play fail sound
	}
}
Beispiel #7
0
void Audio::closedown()
{
//#ifdef _USE_MIKMOD
//	if (_bMusic) modStop();
//#endif

    stopTrack();

	Mix_FreeChunk(_volTest);
    Mix_FreeMusic(_musicTrack);

    std::vector<Mix_Chunk *>::iterator it = _sfxList.begin();
    std::vector<Mix_Chunk *>::iterator end = _sfxList.end();
    for ( ; it!=end; ++it)
    {
        Mix_FreeChunk((*it));
        (*it) = NULL;
    }
    _sfxList.clear();

	if (_init)
	{
        Mix_CloseAudio();
	}

    _init = false;
}
Beispiel #8
0
void Client::setPermission(bool permission)
{
  m_trackingPermitted = permission;
  if ((permission) && (!isTracking()))
    startTrack();
  else
  if ((!permission) && (isTracking()))
    stopTrack();
}
Beispiel #9
0
void Sound::playTrack(const uint16_t* track, uint8_t channel){
#if(NUM_CHANNELS > 0)
	if(channel>=NUM_CHANNELS)
		return;
	stopTrack(channel);
	trackCursor[channel] = 0;
	trackData[channel] = (uint16_t*)track;
	trackIsPlaying[channel] = true;
	//Serial.println("track start");
#endif
}
Beispiel #10
0
void MainWindow::createActions() {
    startAction = new QAction(tr("&Start"), this);
    connect(startAction, SIGNAL(triggered()), this, SLOT(startTrack()));

    stopAction = new QAction(tr("S&top"), this);
    connect(stopAction, SIGNAL(triggered()), this, SLOT(stopTrack()));

    logoutAction = new QAction(tr("Log&out"), this);
    connect(logoutAction, SIGNAL(triggered()), this, SLOT(logout()));

    exitAction = new QAction(tr("E&xit"), this);
    connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
}
Beispiel #11
0
void Client::logout()
{
  if (isTracking())
    stopTrack();
  else
  if (m_additionalTimer->isActive())
    m_additionalTimer->stop();
  Settings::getInstance().setLogin("unknown");
  Settings::getInstance().setPassword("unknown");
  int size = m_contactModel->getContacts().size();
  for (int i=0;i<size;i++)
    m_contactModel->removeContact(m_contactModel->getContacts().at(0)->getChannelName());

}
bool
GUISUMOAbstractView::removeAdditionalGLVisualisation(GUIGlObject* const which) {
    if (getTrackedID() == static_cast<int>(which->getGlID())) {
        stopTrack();
    }
    if (myAdditionallyDrawn.find(which) == myAdditionallyDrawn.end()) {
        return false;
    }
    int cnt = myAdditionallyDrawn[which];
    if (cnt == 1) {
        myAdditionallyDrawn.erase(which);
    } else {
        myAdditionallyDrawn[which] = myAdditionallyDrawn[which] - 1;
    }
    update();
    return true;
}
Beispiel #13
0
// ----------------------------------------------------------------------------
//
bool SpotifyEngine::disconnect( void )
{
    m_track_timer.stopThread();

    if ( m_spotify_session ) {
        // Seems to be very important to stop all active tracks before killing Spotify

        clearTrackQueue( );         // Clear any pending tracks
        stopTrack();                // Stop any playing track(s)
        stopThread();               // Stop the spotify dispatcher

        ULONG future = GetCurrentTime() + (2 * 60 * 1000);

        // Logout the user        
        sp_session_logout( m_spotify_session );
        while ( getLoginState() != NOT_LOGGED_IN ) {
            int next_timeout = 0;
            do {
                sp_session_process_events( m_spotify_session, &next_timeout );
            } while (next_timeout == 0);

            if ( GetCurrentTime() > future )
                break;

            Sleep( 100 );
        }
    }

    if ( m_audio_out ) {
        AudioOutputStream::releaseAudioStream ( m_audio_out );
        m_audio_out = NULL;
    }

    removeTrackAnalyzer();

    freeTrackAnalysisCache();

    return true;
}
Beispiel #14
0
void MainWindow::handleNetworkData(QNetworkReply *networkReply) {
    if (!networkReply->error()) {
        QByteArray response(networkReply->readAll());
        QJsonDocument jsonDoc = QJsonDocument::fromJson(response);

        QJsonObject result = jsonDoc.object();
        QMessageLogger().debug() <<networkReply->objectName();
        if (networkReply->objectName() == "logout") {
            if (result.value("error").toBool(true)) {
                QMessageBox msgBox;
                msgBox.setText(result["error"].toString());
                msgBox.exec();
                QMessageLogger().debug() << response;
            }
        } else if (networkReply->objectName() == "sync") {
            if (result.value("time") != QJsonValue::Undefined) {
                MainWindow::sharedData()->timestamp = (quint32)result.value("time").toDouble();
                timer->start(60000);
            } else {
                if (result.value("error") != QJsonValue::Undefined) {
                    QMessageBox msgBox;
                    msgBox.setText(result["error"].toString());
                    msgBox.exec();
                    QMessageLogger().debug() << response;
                }

                ui->trackBtn->setText("Start");
                isTracking = false;
                this->updateActionsStatus();
                ui->contractsCombo->setEnabled(true);
            }
        } else if (networkReply->objectName() == "timelog") {
            QJsonObject status = result.value("status").toObject();
            QStringList list = status.keys();
            bool success = false;
            int errorCode = 0;
            for (int i=0; i<list.count(); i++) {
                QString key = list.value(i);
                QJsonObject snap = status.value(key).toObject();
                if (snap.value("error").toInt() == 0) {
                    success = true;
                } else {
                    errorCode = snap.value("error").toInt();
                }
            }

            if (success || (errorCode == 2)) {
                trayIcon->showMessage("Screenshot", "Just uploaded screenshot and logs of keyboard and mouse.",QSystemTrayIcon::Information, 5000);
                QString imagePath = networkReply->property("imagePath").toString();
                QFile file(imagePath);
                file.remove();
                if (!isUploadingCache)
                    uploadCacheData();
            } else {
                quint32 timestamp = (quint32)networkReply->property("timestamp").toDouble();
                QString imagePath = networkReply->property("imagePath").toString();
                QByteArray jwt = networkReply->request().rawHeader("JWT");

                QSettings settings("WawJob", "WawTracker");
                settings.setValue("cache/" + QString("%1").arg(timestamp) + "/imagePath", imagePath);
                settings.setValue("cache/" + QString("%1").arg(timestamp) + "/jwt", jwt);
            }
            QFile data("logging.txt");
            if (data.open(QFile::WriteOnly | QFile::Append)) {
                QTextStream out(&data);
                out << response;
            }
            QMessageLogger().debug() << response;
        } else if (networkReply->objectName() == "timelog_cache") {
            QMessageLogger().debug() << response;
            QJsonObject status = result.value("status").toObject();
            QStringList list = status.keys();
            bool success = false;
            int errorCode = 0;
            for (int i=0; i<list.count(); i++) {
                QString key = list.value(i);
                QJsonObject snap = status.value(key).toObject();
                if (snap.value("error").toInt() == 0) {
                    success = true;
                } else {
                    errorCode = snap.value("error").toInt();
                }
            }

            if (success || (errorCode == 2)) {
                QString imagePath = networkReply->property("imagePath").toString();
                QFile file(imagePath);
                file.remove();

                QString timestamp = networkReply->property("timestamp").toString();
                QSettings settings("WawJob", "WawTracker");
                settings.remove("cache/"+timestamp);

                uploadCacheData();
            } else {
                isUploadingCache = false;
            }
        }
    } else {
        if (networkReply->objectName() == "sync") {
            stopTrack();
        } else if (networkReply->objectName() == "timelog") {
            quint32 timestamp = (quint32)networkReply->property("timestamp").toDouble();
            QString imagePath = networkReply->property("imagePath").toString();
            QByteArray jwt = networkReply->request().rawHeader("JWT");

            QSettings settings("WawJob", "WawTracker");
            settings.setValue("cache/" + QString("%1").arg(timestamp) + "/imagePath", imagePath);
            settings.setValue("cache/" + QString("%1").arg(timestamp) + "/jwt", jwt);
        }else if (networkReply->objectName() == "timelog_cache") {
            isUploadingCache = false;
        }else {
            QMessageBox msgBox;
            msgBox.setText(networkReply->errorString());
            msgBox.exec();
        }
        QMessageLogger().debug() <<networkReply->objectName() << networkReply->errorString();
        QFile data("logging.txt");
        if (data.open(QFile::WriteOnly | QFile::Append)) {
            QTextStream out(&data);
            out <<networkReply->objectName() << networkReply->errorString();
        }

    }

    networkReply->deleteLater();
}