Ejemplo n.º 1
0
Tracks::Tracks()
{
	songinfos.push_back( SongInfo( "When Nighttime Falls", 
		hge->Stream_Load( "sound/When Nighttime Falls, I'll be Waiting for Her 10-4d26nesy-110fxd.mp3" )  ) );

	songinfo_it = songinfos.begin();
}
std::shared_ptr<Streamer> MusicPlayer::streamFile(const string &fileName) {
	dontPlay = true;
	silentFrames = 0;

	{
		LOCK_GUARD(infoMutex);
		playingInfo = SongInfo();
	}

	string name = fileName;

	LOCK_GUARD(playerMutex);
	player = nullptr;
	player = fromStream(fileName);

	dontPlay = false;
	playEnded = false;

	if(player) {

		fifo.clear();
		fadeOutPos = 0;
		pause(false);
		pos = 0;
		// updatePlayingInfo();
		currentTune = playingInfo.starttune;
		return make_shared<Streamer>(playerMutex, player);
	}
	return nullptr;
}
Ejemplo n.º 3
0
//---------------------------------------------------------
void PlayerInterface::checkSongChange(SongInfo &song)
{
    if(song.songName != m_currentSong.songName)
    {
        qDebug() << "Song changed: " << song.songName;
        emit songChanged(song);
        m_currentSong = song;

        if(song.isValid())
            downloadSongArt(song.artUrl);

        if(playbackStatus() == Playing && song.isValid())
        {
            m_startedSong = song;
            emit songStarted(song);
        }
        else
            m_startedSong = SongInfo(); // invalid song
    }
    else if(song.isValid() && !m_startedSong.isValid() && playbackStatus() == Playing)
    {
        // sometimes (depends on the player) a new song is active but not playing,
        // we only emit song started when a song is valid and the player is playing.s
        m_startedSong = song;
        emit songStarted(song);
    }
}
Ejemplo n.º 4
0
//---------------------------------------------------------
SongInfo PlayerInterface::currentSong()
{
    IStreamingService* iService =
            Services::streamingServices()->currentService();
    if(!iService)
        return SongInfo(); // invalid song
    return iService->currentSongInfo();
}
Ejemplo n.º 5
0
//---------------------------------------------------------
SongInfo PlayerInterface::update()
{
    IStreamingService* iService =
            Services::streamingServices()->currentService();
    if(!iService)
        return SongInfo();  // invalid song
    SongInfo song = iService->currentSongInfo();
    checkPlaybackStatusChange(song);
    checkSongChange(song);
    checkForPositionChange(song);
    checkForControlCaps();
    return song;
}
Ejemplo n.º 6
0
void main_page::playCollection(int collectionId)
{
    xiamiapi::IGenericArray * list;
    auto api = ((MainWindow *)(context))->api;
    api->GetCollectionPlaylist(collectionId, &list);
    QVector<SongInfo> playlist;
    for (uint64_t i = 0; i < list->length(); ++i)
    {
        xiamiapi::IXiamiPlaylistInfo * info;
        list->get_element(i)->QueryInterface(list->ElementIID(), (void **)&info);
        playlist.append(SongInfo(info->get_song_id(), info->get_title(), info->get_artist(), info->get_location()));
        info->Release();
    }
    list->Release();
    ((MainWindow *)(context))->play(std::move(playlist));
}
bool MusicPlayer::playFile(const string &fileName) {

	dontPlay = true;
	silentFrames = 0;

	{
		LOCK_GUARD(infoMutex);
		playingInfo = SongInfo();
	}

	string name = fileName;

	if(endsWith(name, ".rar")) {
		try {
			auto *a = Archive::open(name, "_files");
			for(const auto &s : *a) {
				a->extract(s);
				name = "_files/" + s;
				LOGD("Extracted %s", name);
				break;
			}
		} catch(archive_exception &ae) {
			LOCK_GUARD(playerMutex);
			player = nullptr;
			return false;
		}
	}

	LOCK_GUARD(playerMutex);
	player = nullptr;
	player = fromFile(name);

	dontPlay = false;
	playEnded = false;

	if(player) {

		fifo.clear();
		fadeOutPos = 0;
		pause(false);
		pos = 0;
		updatePlayingInfo();
		currentTune = playingInfo.starttune;
		return true;
	}
	return false;
}
Ejemplo n.º 8
0
Tracks::Tracks()
{
	songinfos.push_back( SongInfo( "The Last Prophecy", hge->Stream_Load( "sound/SynthR - The Last Prophecy.mp3" )  ) );

	songinfo_it = songinfos.begin();
}