Jelajahi Sumber

Merge pull request #2854 from IvanSavenko/video_player_fix

Fix looped playback of video files
Ivan Savenko 2 tahun lalu
induk
melakukan
f50f32fade
2 mengubah file dengan 10 tambahan dan 6 penghapusan
  1. 3 1
      client/CVideoHandler.cpp
  2. 7 5
      client/CVideoHandler.h

+ 3 - 1
client/CVideoHandler.cpp

@@ -17,6 +17,7 @@
 #include "renderSDL/SDL_Extensions.h"
 #include "CPlayerInterface.h"
 #include "../lib/filesystem/Filesystem.h"
+#include "../lib/filesystem/CInputStream.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);
 		else
 		{
-			open(fname);
+			VideoPath filenameToReopen = fname; // create copy to backup this->fname
+			open(filenameToReopen);
 			nextFrame();
 
 			// The y position is wrong at the first frame.

+ 7 - 5
client/CVideoHandler.h

@@ -15,7 +15,7 @@
 struct SDL_Surface;
 struct SDL_Texture;
 
-class IVideoPlayer
+class IVideoPlayer : boost::noncopyable
 {
 public:
 	virtual bool open(const VideoPath & name, bool scale = false)=0; //true - succes
@@ -31,8 +31,6 @@ public:
 class IMainVideoPlayer : public IVideoPlayer
 {
 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 bool openAndPlayVideo(const VideoPath & name, int x, int y, bool stopOnKey = false, bool scale = false)
 	{
@@ -55,14 +53,16 @@ public:
 
 #ifndef DISABLE_VIDEO
 
-#include "../lib/filesystem/CInputStream.h"
-
 struct AVFormatContext;
 struct AVCodecContext;
 struct AVCodec;
 struct AVFrame;
 struct AVIOContext;
 
+VCMI_LIB_NAMESPACE_BEGIN
+class CInputStream;
+VCMI_LIB_NAMESPACE_END
+
 class CVideoPlayer : public IMainVideoPlayer
 {
 	int stream;					// stream index in video
@@ -74,6 +74,8 @@ class CVideoPlayer : public IMainVideoPlayer
 
 	AVIOContext * context;
 
+	VideoPath fname;  //name of current video file (empty if idle)
+
 	// Destination. Either overlay or dest.
 
 	SDL_Texture *texture;