- video player now displays 'please wait' while loading the video
This commit is contained in:
parent
e61a17972e
commit
0fac755a5e
|
@ -1801,12 +1801,13 @@ int Game::getFirstUnusedTeamNumber() {
|
|||
|
||||
void Game::setupRenderForVideo() {
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
renderer.clearBuffers();
|
||||
//renderer.clearBuffers();
|
||||
//3d
|
||||
renderer.reset3dMenu();
|
||||
renderer.clearZBuffer();
|
||||
//renderer.reset3dMenu();
|
||||
//renderer.clearZBuffer();
|
||||
//2d
|
||||
renderer.reset2d();
|
||||
//renderer.reset2d();
|
||||
renderer.setupRenderForVideo();
|
||||
}
|
||||
|
||||
void Game::tryPauseToggle(bool pauseValue) {
|
||||
|
@ -3726,7 +3727,9 @@ void Game::playStreamingVideo(const string &playVideo) {
|
|||
|
||||
string vlcPluginsPath = Config::getInstance().getString("VideoPlayerPluginsPath","");
|
||||
|
||||
videoPlayer = new Shared::Graphics::VideoPlayer(playVideo.c_str(),
|
||||
videoPlayer = new Shared::Graphics::VideoPlayer(
|
||||
&Renderer::getInstance(),
|
||||
playVideo.c_str(),
|
||||
screen,
|
||||
0,0,
|
||||
screen->w,
|
||||
|
@ -3748,14 +3751,16 @@ void Game::playStreamingVideo(const string &playVideo) {
|
|||
|
||||
string vlcPluginsPath = Config::getInstance().getString("VideoPlayerPluginsPath","");
|
||||
|
||||
videoPlayer = new Shared::Graphics::VideoPlayer(playVideo.c_str(),
|
||||
screen,
|
||||
0,0,
|
||||
screen->w,
|
||||
screen->h,
|
||||
screen->format->BitsPerPixel,
|
||||
vlcPluginsPath,
|
||||
SystemFlags::VERBOSE_MODE_ENABLED);
|
||||
videoPlayer = new Shared::Graphics::VideoPlayer(
|
||||
&Renderer::getInstance(),
|
||||
playVideo.c_str(),
|
||||
screen,
|
||||
0,0,
|
||||
screen->w,
|
||||
screen->h,
|
||||
screen->format->BitsPerPixel,
|
||||
vlcPluginsPath,
|
||||
SystemFlags::VERBOSE_MODE_ENABLED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8533,4 +8533,47 @@ void Renderer::renderPopupMenu(PopupMenu *menu) {
|
|||
|
||||
}
|
||||
|
||||
void Renderer::setupRenderForVideo() {
|
||||
clearBuffers();
|
||||
//3d
|
||||
reset3dMenu();
|
||||
clearZBuffer();
|
||||
//2d
|
||||
reset2d();
|
||||
glClearColor(0.f, 0.f, 0.f, 1.f);
|
||||
}
|
||||
|
||||
void Renderer::renderVideoLoading(int progressPercent) {
|
||||
//printf("Rendering progress progressPercent = %d\n",progressPercent);
|
||||
setupRenderForVideo();
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
string textToRender = lang.get("PleaseWait");
|
||||
const Metrics &metrics= Metrics::getInstance();
|
||||
|
||||
if(CoreData::getInstance().getMenuFontBig3D() != NULL) {
|
||||
|
||||
int renderX = 0;
|
||||
int renderY = 0;
|
||||
int w= metrics.getVirtualW();
|
||||
renderX = (w / 2) - (CoreData::getInstance().getMenuFontBig3D()->getMetrics()->getTextWidth(textToRender) / 2);
|
||||
int h= metrics.getVirtualH();
|
||||
renderY = (h / 2) + (CoreData::getInstance().getMenuFontBig3D()->getMetrics()->getHeight(textToRender) / 2);
|
||||
|
||||
renderText3D(
|
||||
textToRender,
|
||||
CoreData::getInstance().getMenuFontBig3D(),
|
||||
Vec3f(1.f, 1.f, 0.f),
|
||||
renderX, renderY, false);
|
||||
}
|
||||
else {
|
||||
renderText(
|
||||
textToRender,
|
||||
CoreData::getInstance().getMenuFontBig(),
|
||||
Vec3f(1.f, 1.f, 0.f), (metrics.getScreenW() / 2),
|
||||
(metrics.getScreenH() / 2), true);
|
||||
}
|
||||
swapBuffers();
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "graphics_interface.h"
|
||||
#include "base_renderer.h"
|
||||
#include "simple_threads.h"
|
||||
#include "video_player.h"
|
||||
|
||||
#ifdef DEBUG_RENDERING_ENABLED
|
||||
# define IF_DEBUG_EDITION(x) x
|
||||
|
@ -179,7 +180,8 @@ public:
|
|||
class Renderer : public RendererInterface,
|
||||
public BaseRenderer,
|
||||
// This is for screen saver thread
|
||||
public SimpleTaskCallbackInterface {
|
||||
public SimpleTaskCallbackInterface,
|
||||
public VideoLoadingCallbackInterface {
|
||||
public:
|
||||
//progress bar
|
||||
static const int maxProgressBar;
|
||||
|
@ -591,6 +593,9 @@ public:
|
|||
|
||||
void setProgram(Program *program) { this->program = program; }
|
||||
|
||||
void setupRenderForVideo();
|
||||
virtual void renderVideoLoading(int progressPercent);
|
||||
|
||||
private:
|
||||
//private misc
|
||||
float computeSunAngle(float time);
|
||||
|
|
|
@ -498,19 +498,27 @@ Intro::Intro(Program *program):
|
|||
CoreData::getInstance().hasIntroVideoFilename() == true) {
|
||||
string introVideoFile = CoreData::getInstance().getIntroVideoFilename();
|
||||
//if(fileExists(introVideoFile)) {
|
||||
|
||||
renderer.clearBuffers();
|
||||
renderer.reset3dMenu();
|
||||
renderer.clearZBuffer();
|
||||
renderer.reset2d();
|
||||
|
||||
Context *c= GraphicsInterface::getInstance().getCurrentContext();
|
||||
SDL_Surface *screen = static_cast<ContextGl*>(c)->getPlatformContextGlPtr()->getScreen();
|
||||
|
||||
string vlcPluginsPath = Config::getInstance().getString("VideoPlayerPluginsPath","");
|
||||
//printf("screen->w = %d screen->h = %d screen->format->BitsPerPixel = %d\n",screen->w,screen->h,screen->format->BitsPerPixel);
|
||||
Shared::Graphics::VideoPlayer player(introVideoFile.c_str(),
|
||||
screen,
|
||||
-1,-1,
|
||||
screen->w,
|
||||
screen->h,
|
||||
screen->format->BitsPerPixel,
|
||||
vlcPluginsPath,
|
||||
SystemFlags::VERBOSE_MODE_ENABLED);
|
||||
Shared::Graphics::VideoPlayer player(
|
||||
&Renderer::getInstance(),
|
||||
introVideoFile.c_str(),
|
||||
screen,
|
||||
0,0,
|
||||
screen->w,
|
||||
screen->h,
|
||||
screen->format->BitsPerPixel,
|
||||
vlcPluginsPath,
|
||||
SystemFlags::VERBOSE_MODE_ENABLED);
|
||||
player.PlayVideo();
|
||||
exitAfterIntroVideo = true;
|
||||
return;
|
||||
|
|
|
@ -105,14 +105,16 @@ void MainMenu::init() {
|
|||
|
||||
string vlcPluginsPath = Config::getInstance().getString("VideoPlayerPluginsPath","");
|
||||
//printf("screen->w = %d screen->h = %d screen->format->BitsPerPixel = %d\n",screen->w,screen->h,screen->format->BitsPerPixel);
|
||||
menuBackgroundVideo = new VideoPlayer(introVideoFile.c_str(),
|
||||
screen,
|
||||
0,0,
|
||||
screen->w,
|
||||
screen->h,
|
||||
screen->format->BitsPerPixel,
|
||||
vlcPluginsPath,
|
||||
SystemFlags::VERBOSE_MODE_ENABLED);
|
||||
menuBackgroundVideo = new VideoPlayer(
|
||||
&Renderer::getInstance(),
|
||||
introVideoFile.c_str(),
|
||||
screen,
|
||||
0,0,
|
||||
screen->w,
|
||||
screen->h,
|
||||
screen->format->BitsPerPixel,
|
||||
vlcPluginsPath,
|
||||
SystemFlags::VERBOSE_MODE_ENABLED);
|
||||
menuBackgroundVideo->initPlayer();
|
||||
//}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,12 @@ using namespace std;
|
|||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
class VideoLoadingCallbackInterface {
|
||||
public:
|
||||
/** a value from 1 to 100 representing % done */
|
||||
virtual void renderVideoLoading(int progressPercent) = 0;
|
||||
};
|
||||
|
||||
class VideoPlayer {
|
||||
protected:
|
||||
|
||||
|
@ -38,12 +44,13 @@ protected:
|
|||
bool stop;
|
||||
bool finished;
|
||||
|
||||
VideoLoadingCallbackInterface *loadingCB;
|
||||
ctx *ctxPtr;
|
||||
|
||||
void init();
|
||||
|
||||
public:
|
||||
VideoPlayer(string filename, SDL_Surface *surface, int x, int y,
|
||||
VideoPlayer(VideoLoadingCallbackInterface *loadingCB, string filename, SDL_Surface *surface, int x, int y,
|
||||
int width, int height, int colorBits,
|
||||
string pluginsPath,bool verboseEnabled=false);
|
||||
virtual ~VideoPlayer();
|
||||
|
|
|
@ -70,6 +70,7 @@ std::string getRegKey(const std::string& location, const std::string& name){
|
|||
class ctx {
|
||||
public:
|
||||
ctx() {
|
||||
loadingCB = NULL;
|
||||
empty = NULL;
|
||||
textureId = 0; // Texture ID
|
||||
surf = NULL;
|
||||
|
@ -99,6 +100,7 @@ public:
|
|||
#endif
|
||||
}
|
||||
|
||||
Shared::Graphics::VideoLoadingCallbackInterface *loadingCB;
|
||||
SDL_Surface *empty;
|
||||
GLuint textureId; // Texture ID
|
||||
SDL_Surface *surf;
|
||||
|
@ -399,9 +401,10 @@ void callbacks( const libvlc_event_t* event, void* data ) {
|
|||
|
||||
#endif
|
||||
|
||||
VideoPlayer::VideoPlayer(string filename, SDL_Surface *surface,
|
||||
VideoPlayer::VideoPlayer(VideoLoadingCallbackInterface *loadingCB, string filename, SDL_Surface *surface,
|
||||
int x, int y,int width, int height,int colorBits,string pluginsPath,
|
||||
bool verboseEnabled) : ctxPtr(NULL) {
|
||||
this->loadingCB = loadingCB;
|
||||
this->filename = filename;
|
||||
this->surface = surface;
|
||||
this->x = x;
|
||||
|
@ -421,6 +424,7 @@ VideoPlayer::VideoPlayer(string filename, SDL_Surface *surface,
|
|||
|
||||
void VideoPlayer::init() {
|
||||
ctxPtr = new ctx();
|
||||
ctxPtr->loadingCB = loadingCB;
|
||||
ctxPtr->x = x;
|
||||
ctxPtr->y = y;
|
||||
ctxPtr->width = width;
|
||||
|
@ -605,7 +609,7 @@ bool VideoPlayer::initPlayer() {
|
|||
*/
|
||||
|
||||
const string HTTP_PREFIX = "http";
|
||||
const double MAX_VIDEO_START_MILLISECONDS = 20;
|
||||
const double MAX_VIDEO_START_MILLISECONDS = 20.0;
|
||||
|
||||
if(ctxPtr->libvlc != NULL) {
|
||||
#if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
|
||||
|
@ -906,7 +910,11 @@ bool VideoPlayer::initPlayer() {
|
|||
if(ctxPtr->started == true) {
|
||||
break;
|
||||
}
|
||||
SDL_Delay(10);
|
||||
if(this->loadingCB != NULL) {
|
||||
int progress = ((difftime(time(NULL),waitStart) / MAX_VIDEO_START_MILLISECONDS) * 100.0);
|
||||
this->loadingCB->renderVideoLoading(progress);
|
||||
}
|
||||
SDL_Delay(1);
|
||||
}
|
||||
|
||||
//SDL_Delay(5000);
|
||||
|
|
Loading…
Reference in New Issue