void Transport::Start(utfstring url){
#ifdef _DEBUG
	std::cerr << "Transport::Start called" << std::endl;
#endif
    // Check if this is already Prepared
    PlayerPtr player    = this->nextPlayer;
    this->nextPlayer.reset();
#ifdef _DEBUG
	std::cerr << "Transport: nextPlayer reset" << std::endl;
#endif

    // If the nextPlayer wasn't the same as the one started, lets create a new one
    if(!player || player->url!=url){
        // Or create a new player
    	Player::OutputPtr output;
#ifdef _DEBUG
	std::cerr << "Transport: new output created for player" << std::endl;
#endif
        player  = Player::Create(url, &output);
        player->SetVolume(this->volume);
#ifdef _DEBUG
	std::cerr << "Transport: new player created" << std::endl;
#endif
    }

    // Add to the players
    this->players.push_front(player);
    this->currentPlayer = player;
#ifdef _DEBUG
	std::cerr << "Transport: player added to player list" << std::endl;
#endif

    // Lets connect to the signals of the currentPlayer
    this->currentPlayer->PlaybackStarted.connect(this,&Transport::OnPlaybackStarted);
    this->currentPlayer->PlaybackAlmostEnded.connect(this,&Transport::OnPlaybackAlmostEnded);
    this->currentPlayer->PlaybackEnded.connect(this,&Transport::OnPlaybackEnded);
    this->currentPlayer->PlaybackError.connect(this, &Transport::OnPlaybackError);
#ifdef _DEBUG
	std::cerr << "Transport: player-Play() about to be called" << std::endl;
#endif
    // Start playing
    player->Play();
}
Beispiel #2
0
GS_PLAYER_INFO PlayCutscene(VideoPtr pVideo, const std::wstring& fileName,
							InputPtr pInput, const GS_KEY escapeKey)
{
	if (!pVideo)
	{
		ShowMessage(L"Invalid video handler - gs2d::PlayCutscene", GSMT_ERROR);
		return GSPI_FAILED;
	}

	GS_PLAYER_INFO info = GSPI_FINISHED;
	//pVideo->TurnLoopManagerOff();

	const bool rendering = pVideo->Rendering();
	if (rendering)
		pVideo->EndSpriteScene();

	PlayerPtr player = CreatePlayer(pVideo, fileName);
	if (!player)
	{
		ShowMessage(L"Failed while trying to load the video - gs2d::PlayCutscene", GSMT_ERROR);
		if (rendering)
			pVideo->BeginSpriteScene();
		return GSPI_FAILED;
	}

	pVideo->EnableMediaPlaying(true);
	player->SetFullscreen();
	player->Rewind();
	player->Play();

	while (!player->IsFinished())
	{
		player->UpdateVideo();
		const Video::APP_STATUS status = pVideo->HandleEvents();
		if (status == Video::APP_QUIT)
		{
			info = GSPI_CLOSE_WINDOW;
			break;
		}
		else
		{
			if (status == Video::APP_SKIP)
				continue;
		}

		if (pInput)
		{
			pInput->Update();
			if (pInput->GetKeyState(escapeKey) == GSKS_HIT)
			{
				info = GSPI_SKIPPED;
				break;
			}
		}
	}

	if (rendering)
		pVideo->BeginSpriteScene();

	pVideo->EnableMediaPlaying(false);
	return info;
}