- proper implementation of video repeat (looping)

This commit is contained in:
Mark Vejvoda 2012-09-27 01:17:57 +00:00
parent c4ead34ad3
commit c33c1826ae
8 changed files with 37 additions and 2 deletions

View File

@ -4571,6 +4571,7 @@ void Game::playStreamingVideo(const string &playVideo) {
screen->w,
screen->h,
screen->format->BitsPerPixel,
false,
vlcPluginsPath,
SystemFlags::VERBOSE_MODE_ENABLED);
}
@ -4596,6 +4597,7 @@ void Game::playStreamingVideo(const string &playVideo) {
screen->w,
screen->h,
screen->format->BitsPerPixel,
false,
vlcPluginsPath,
SystemFlags::VERBOSE_MODE_ENABLED);
}

View File

@ -338,6 +338,7 @@ void BattleEnd::initBackgroundVideo() {
screen->w,
screen->h,
screen->format->BitsPerPixel,
true,
vlcPluginsPath,
SystemFlags::VERBOSE_MODE_ENABLED);
menuBackgroundVideo->initPlayer();

View File

@ -526,6 +526,7 @@ Intro::Intro(Program *program):
screen->w,
screen->h,
screen->format->BitsPerPixel,
false,
vlcPluginsPath,
SystemFlags::VERBOSE_MODE_ENABLED);
player.PlayVideo();

View File

@ -128,6 +128,7 @@ void MainMenu::initBackgroundVideo() {
screen->w,
screen->h,
screen->format->BitsPerPixel,
true,
vlcPluginsPath,
SystemFlags::VERBOSE_MODE_ENABLED);
menuBackgroundVideo->initPlayer();

View File

@ -3857,6 +3857,7 @@ void MenuStateConnectedGame::initFactionPreview(const GameSettings *gameSettings
screen->w,
screen->h,
screen->format->BitsPerPixel,
true,
vlcPluginsPath,
SystemFlags::VERBOSE_MODE_ENABLED);
factionVideo->initPlayer();

View File

@ -2744,6 +2744,7 @@ void MenuStateCustomGame::initFactionPreview(const GameSettings *gameSettings) {
screen->w,
screen->h,
screen->format->BitsPerPixel,
true,
vlcPluginsPath,
SystemFlags::VERBOSE_MODE_ENABLED);
factionVideo->initPlayer();

View File

@ -45,6 +45,7 @@ protected:
bool stop;
bool finished;
bool loop;
VideoLoadingCallbackInterface *loadingCB;
ctx *ctxPtr;
@ -61,7 +62,7 @@ public:
string filenameFallback,
SDL_Surface *surface, int x, int y,
int width, int height, int colorBits,
string pluginsPath,bool verboseEnabled=false);
bool loop, string pluginsPath,bool verboseEnabled=false);
virtual ~VideoPlayer();
static void setDisabled(bool value) { disabled = value; }

View File

@ -412,7 +412,9 @@ VideoPlayer::VideoPlayer(VideoLoadingCallbackInterface *loadingCB,
string filenameFallback,
SDL_Surface *surface,
int x, int y,int width, int height,int colorBits,
string pluginsPath, bool verboseEnabled) : ctxPtr(NULL) {
bool loop, string pluginsPath, bool verboseEnabled)
: ctxPtr(NULL) {
this->loadingCB = loadingCB;
this->filename = filename;
this->filenameFallback = filenameFallback;
@ -422,6 +424,7 @@ VideoPlayer::VideoPlayer(VideoLoadingCallbackInterface *loadingCB,
this->width = width;
this->height = height;
this->colorBits = colorBits;
this->loop = loop;
this->pluginsPath = pluginsPath;
//this->verboseEnabled = true;
this->verboseEnabled = verboseEnabled;
@ -492,6 +495,11 @@ bool VideoPlayer::initPlayer(string mediaURL) {
ctxPtr->vlc_argv.push_back("--no-video-title-show");
//ctxPtr->vlc_argv.push_back("--network-caching=10000");
if(loop == true) {
ctxPtr->vlc_argv.push_back("--loop");
ctxPtr->vlc_argv.push_back("--repeat");
}
#if defined(LIBVLC_VERSION_PRE_2)
ctxPtr->vlc_argv_str.push_back("--plugin-path=" + pluginsPath);
ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str());
@ -659,6 +667,10 @@ bool VideoPlayer::initPlayer(string mediaURL) {
/* Create a new item */
if(verboseEnabled) printf("In [%s] Line: %d, m [%p]\n",__FUNCTION__,__LINE__,ctxPtr->m);
if(loop == true) {
libvlc_media_add_option(ctxPtr->m, "input-repeat=-1");
}
if(mediaURL.find(HTTP_PREFIX) == 0) {
ctxPtr->mp = libvlc_media_player_new(ctxPtr->libvlc);
}
@ -1401,6 +1413,21 @@ bool VideoPlayer::playFrame(bool swapBuffers) {
}
void VideoPlayer::RestartVideo() {
printf("Restart video\n");
this->stop = false;
this->finished = false;
ctxPtr->started = true;
ctxPtr->error = false;
ctxPtr->stopped = false;
ctxPtr->end_of_media = false;
ctxPtr->isPlaying = true;
ctxPtr->needToQuit = false;
return;
this->closePlayer();
this->stop = false;
this->finished = false;
this->successLoadingLib = false;