mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
Merge pull request #2854 from IvanSavenko/video_player_fix
Fix looped playback of video files
This commit is contained in:
@ -17,6 +17,7 @@
|
|||||||
#include "renderSDL/SDL_Extensions.h"
|
#include "renderSDL/SDL_Extensions.h"
|
||||||
#include "CPlayerInterface.h"
|
#include "CPlayerInterface.h"
|
||||||
#include "../lib/filesystem/Filesystem.h"
|
#include "../lib/filesystem/Filesystem.h"
|
||||||
|
#include "../lib/filesystem/CInputStream.h"
|
||||||
|
|
||||||
#include <SDL_render.h>
|
#include <SDL_render.h>
|
||||||
|
|
||||||
@ -367,7 +368,8 @@ void CVideoPlayer::update( int x, int y, SDL_Surface *dst, bool forceRedraw, boo
|
|||||||
show(x,y,dst,update);
|
show(x,y,dst,update);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
open(fname);
|
VideoPath filenameToReopen = fname; // create copy to backup this->fname
|
||||||
|
open(filenameToReopen);
|
||||||
nextFrame();
|
nextFrame();
|
||||||
|
|
||||||
// The y position is wrong at the first frame.
|
// The y position is wrong at the first frame.
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
struct SDL_Surface;
|
struct SDL_Surface;
|
||||||
struct SDL_Texture;
|
struct SDL_Texture;
|
||||||
|
|
||||||
class IVideoPlayer
|
class IVideoPlayer : boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual bool open(const VideoPath & name, bool scale = false)=0; //true - succes
|
virtual bool open(const VideoPath & name, bool scale = false)=0; //true - succes
|
||||||
@ -31,8 +31,6 @@ public:
|
|||||||
class IMainVideoPlayer : public IVideoPlayer
|
class IMainVideoPlayer : public IVideoPlayer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VideoPath fname; //name of current video file (empty if idle)
|
|
||||||
|
|
||||||
virtual void update(int x, int y, SDL_Surface *dst, bool forceRedraw, bool update = true){}
|
virtual void update(int x, int y, SDL_Surface *dst, bool forceRedraw, bool update = true){}
|
||||||
virtual bool openAndPlayVideo(const VideoPath & name, int x, int y, bool stopOnKey = false, bool scale = false)
|
virtual bool openAndPlayVideo(const VideoPath & name, int x, int y, bool stopOnKey = false, bool scale = false)
|
||||||
{
|
{
|
||||||
@ -55,14 +53,16 @@ public:
|
|||||||
|
|
||||||
#ifndef DISABLE_VIDEO
|
#ifndef DISABLE_VIDEO
|
||||||
|
|
||||||
#include "../lib/filesystem/CInputStream.h"
|
|
||||||
|
|
||||||
struct AVFormatContext;
|
struct AVFormatContext;
|
||||||
struct AVCodecContext;
|
struct AVCodecContext;
|
||||||
struct AVCodec;
|
struct AVCodec;
|
||||||
struct AVFrame;
|
struct AVFrame;
|
||||||
struct AVIOContext;
|
struct AVIOContext;
|
||||||
|
|
||||||
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
class CInputStream;
|
||||||
|
VCMI_LIB_NAMESPACE_END
|
||||||
|
|
||||||
class CVideoPlayer : public IMainVideoPlayer
|
class CVideoPlayer : public IMainVideoPlayer
|
||||||
{
|
{
|
||||||
int stream; // stream index in video
|
int stream; // stream index in video
|
||||||
@ -74,6 +74,8 @@ class CVideoPlayer : public IMainVideoPlayer
|
|||||||
|
|
||||||
AVIOContext * context;
|
AVIOContext * context;
|
||||||
|
|
||||||
|
VideoPath fname; //name of current video file (empty if idle)
|
||||||
|
|
||||||
// Destination. Either overlay or dest.
|
// Destination. Either overlay or dest.
|
||||||
|
|
||||||
SDL_Texture *texture;
|
SDL_Texture *texture;
|
||||||
|
Reference in New Issue
Block a user