IVideoPlayer.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * IVideoPlayer.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "../lib/filesystem/ResourcePath.h"
  12. class Canvas;
  13. VCMI_LIB_NAMESPACE_BEGIN
  14. class Point;
  15. VCMI_LIB_NAMESPACE_END
  16. class IVideoInstance
  17. {
  18. public:
  19. /// Returns true if video playback is over
  20. virtual bool videoEnded() = 0;
  21. /// Returns dimensions of the video
  22. virtual Point size() = 0;
  23. /// Displays current frame at specified position
  24. virtual void show(const Point & position, Canvas & canvas) = 0;
  25. /// Advances video playback by specified duration
  26. virtual void tick(uint32_t msPassed) = 0;
  27. virtual ~IVideoInstance() = default;
  28. };
  29. class IVideoPlayer : boost::noncopyable
  30. {
  31. public:
  32. /// Plays video on top of the screen, returns only after playback is over, aborts on input event
  33. virtual bool playIntroVideo(const VideoPath & name) = 0;
  34. /// Plays video on top of the screen, returns only after playback is over
  35. virtual void playSpellbookAnimation(const VideoPath & name, const Point & position) = 0;
  36. /// Load video from specified path. Returns nullptr on failure
  37. virtual std::unique_ptr<IVideoInstance> open(const VideoPath & name, bool scaleToScreen) = 0;
  38. /// Extracts audio data from provided video in wav format. Return nullptr on failure
  39. virtual std::pair<std::unique_ptr<ui8[]>, si64> getAudio(const VideoPath & videoToOpen) = 0;
  40. virtual ~IVideoPlayer() = default;
  41. };